Re: [edk2] [Patch] MdePkg: Add Ipmi2.0 definitions head file.

2015-11-26 Thread Yao, Jiewen
Thanks for the great work to add generic IPMI definition.

Here is my thought:

1) It is good to split header file definition to some small .h.
Can we add more description in each function header description, so that people 
can know where to find the data structure?
For example:
+++ b/MdePkg/Include/IndustryStandard/IpmiNetFnAppDefinitions.h
+/** @file   
+  IPMI 2.0 definitions from the IPMI Specification, revision 2.0
+
+  This file contains all NetFn App commands, including:
+IPM Device "Global" Commands (Chapter 20)
+Firmware Firewall & Command Discovery Commands (Chapter 21)
+BMC Watchdog Timer Commands (Chapter 27)
+BMC Device and Messaging Commands (Chapter 22)
+RMCP+ Support and Payload Commands (Chapter 24)
+
+  See IPMI specification, Appendix G, Command Assignments
+  and Appendix H, Sub-function Assignments.
+
+  Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.

2) Also, can we add Command category info before each sub section? For example:

+//
+//  Below is Definitions for IPM Device "Global" Commands  (Chapter 20)
+//
+
+//
+//  Definitions for Get Device ID command   
+//
+#define IPMI_APP_GET_DEVICE_ID 0x1
..

+//
+//  Below is Definitions for BMC Watchdog Timer Commands (Chapter 27)
+//
+
+//
+//  Definitions for Reset WatchDog Timer command
+//
+#define IPMI_APP_RESET_WATCHDOG_TIMER  0x22

3) I suggest to use full name of NetFn.
IpmiNetFnGroupExtDefinitions.h -> IpmiNetFnGroupExtensionDefinitions.h

4) It is good way to always add IPMI prefix to data structure definition and 
enum type, to avoid conflict with others.
Most of them are OK, while I found below missing.

+typedef enum {
+  Unspecified,
+  StaticAddrsss,
+  DynamicAddressBmcDhcp,
+  DynamicAddressBiosDhcp,
+  DynamicAddressBmcNonDhcp
+} IPMI_IP_ADDRESS_SRC;

+typedef struct {
+  UINT8 IpAddressSelector : 4;
+  UINT8 Reserved1 : 4;
+  union {
+UINT32  IpAddressLong;
+UINT8   IpAddress[4];
+  } PPP_IP_ADDRESS;
+} DESTINATION_IP_ADDRESS;
+
+typedef struct {
+  UINT8 TapSelector;
+  UINT8 TapServiceSelector : 4;
+  UINT8 TapDialStringSelector : 4;
+} DESTINATION_TAP_ACCOUNT;
+
+typedef struct {
+  UINT8 TapSelector;
+  UINT8 PagerIdString[16];
+} TAP_PAGER_ID_STRING;
+




-Original Message-
From: Bu, Daocheng 
Sent: Thursday, November 26, 2015 4:23 PM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen
Subject: [Patch] MdePkg: Add Ipmi2.0 definitions head file.

Add Ipmi2.0 definitions head file based on Ipmi category:
App, Storage and etc.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daocheng Bu 
CC: Jiewen Yao 
---
 MdePkg/Include/IndustryStandard/Ipmi.h |  26 +
 .../IndustryStandard/IpmiNetFnAppDefinitions.h | 614 +
 .../IndustryStandard/IpmiNetFnBridgeDefinitions.h  | 238 
 .../IndustryStandard/IpmiNetFnChassisDefinitions.h | 294 ++
 .../IpmiNetFnFirmwareDefinitions.h |  26 +
 .../IpmiNetFnGroupExtDefinitions.h |  26 +
 .../IpmiNetFnSensorEventDefinitions.h  |  44 ++
 .../IndustryStandard/IpmiNetFnStorageDefinitions.h | 514 +
 .../IpmiNetFnTransportDefinitions.h| 531 ++
 9 files changed, 2313 insertions(+)
 create mode 100644 MdePkg/Include/IndustryStandard/Ipmi.h
 create mode 100644 MdePkg/Include/IndustryStandard/IpmiNetFnAppDefinitions.h
 create mode 100644 MdePkg/Include/IndustryStandard/IpmiNetFnBridgeDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnChassisDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnFirmwareDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnGroupExtDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnSensorEventDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnStorageDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnTransportDefinitions.h

diff --git a/MdePkg/Include/IndustryStandard/Ipmi.h 
b/MdePkg/Include/IndustryStandard/Ipmi.h
new file mode 100644
index 000..de72bcc
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Ipmi.h
@@ -0,0 +1,26 @@
+/** @file   
+  IPMI 2.0 definitions from the IPMI Specification, revision 2.0
+
+  Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.
+  This program and the accompanying materials  
+  are licensed and made available under the terms and conditions of the BSD 
License 
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php   
 
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED. 
+**/
+
+#ifndef _IPMIDEFINITIONS_H_
+#define _IPMIDEFINITIONS_H_
+
+#include 
+#include 

[edk2] [PATCH v5 22/33] OvmfPkg: SmmCpuFeaturesLib: remove unnecessary bits

2015-11-26 Thread Laszlo Ersek
From: Paolo Bonzini 

SMRR, MTRR, and SMM Feature Control support is not needed on a virtual
platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paolo Bonzini 
Acked-by: Laszlo Ersek 
[ler...@redhat.com: insert space between ASSERT and (), convert to CRLF,
 refresh against SVN r18958]
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---

Notes:
v5:
- refresh patch against SVN r18958 ("Add 2 APIs in SmmCpuFeaturesLib")
- drop Mike's R-b consequently

v3:
- new in v3

 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf |   4 -
 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c   | 233 
++--
 2 files changed, 17 insertions(+), 220 deletions(-)

diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index deb08bf..aa4792c 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -32,8 +32,4 @@ [Packages]
 [LibraryClasses]
   BaseLib
   PcdLib
-  MemoryAllocationLib
   DebugLib
-
-[Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber## 
SOMETIMES_CONSUMES
diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
index 3e480e1..3b6f186 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -15,58 +15,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
-//
-// Machine Specific Registers (MSRs)
-//
-#define  SMM_FEATURES_LIB_IA32_MTRR_CAP0x0FE
-#define  SMM_FEATURES_LIB_IA32_FEATURE_CONTROL 0x03A
-#define  SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE   0x1F2
-#define  SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK   0x1F3
-#define  SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE  0x0A0
-#define  SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK  0x0A1
-#defineEFI_MSR_SMRR_MASK   0xF000
-#defineEFI_MSR_SMRR_PHYS_MASK_VALIDBIT11
-#define  SMM_FEATURES_LIB_SMM_FEATURE_CONTROL  0x4E0
-
-//
-// MSRs required for configuration of SMM Code Access Check
-//
-#define SMM_FEATURES_LIB_IA32_MCA_CAP  0x17D
-#define   SMM_CODE_ACCESS_CHK_BIT  BIT58
-
-//
-// Set default value to assume SMRR is not supported
-//
-BOOLEAN  mSmrrSupported = FALSE;
-
-//
-// Set default value to assume MSR_SMM_FEATURE_CONTROL is not supported
-//
-BOOLEAN  mSmmFeatureControlSupported = FALSE;
-
-//
-// Set default value to assume IA-32 Architectural MSRs are used
-//
-UINT32  mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE;
-UINT32  mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK;
-
-//
-// Set default value to assume MTRRs need to be configured on each SMI
-//
-BOOLEAN  mNeedConfigureMtrrs = TRUE;
-
-//
-// Array for state of SMRR enable on all CPUs
-//
-BOOLEAN  *mSmrrEnabled;
-
 /**
   The constructor function
 
@@ -83,91 +36,9 @@ SmmCpuFeaturesLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  UINT32  RegEax;
-  UINT32  RegEdx;
-  UINTN   FamilyId;
-  UINTN   ModelId;
-
   //
-  // Retrieve CPU Family and Model
+  // No need to program SMRRs on our virtual platform.
   //
-  AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx);
-  FamilyId = (RegEax >> 8) & 0xf;
-  ModelId  = (RegEax >> 4) & 0xf;
-  if (FamilyId == 0x06 || FamilyId == 0x0f) {
-ModelId = ModelId | ((RegEax >> 12) & 0xf0);
-  }
-
-  //
-  // Check CPUID(CPUID_VERSION_INFO).EDX[12] for MTRR capability
-  //
-  if ((RegEdx & BIT12) != 0) {
-//
-// Check MTRR_CAP MSR bit 11 for SMRR support
-//
-if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MTRR_CAP) & BIT11) != 0) {
-  mSmrrSupported = TRUE;
-}
-  }
-
-  //
-  // Intel(R) 64 and IA-32 Architectures Software Developer's Manual
-  // Volume 3C, Section 35.3 MSRs in the Intel(R) Atom(TM) Processor Family
-  //
-  // If CPU Family/Model is 06_1CH, 06_26H, 06_27H, 06_35H or 06_36H, then
-  // SMRR Physical Base and SMM Physical Mask MSRs are not available.
-  //
-  if (FamilyId == 0x06) {
-if (ModelId == 0x1C || ModelId == 0x26 || ModelId == 0x27 || ModelId == 
0x35 || ModelId == 0x36) {
-  mSmrrSupported = FALSE;
-}
-  }
-
-  //
-  // Intel(R) 64 and IA-32 Architectures Software Developer's Manual
-  // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Family
-  //
-  // If CPU Family/Model is 06_0F or 06_17, then use Intel(R) Core(TM) 2
-  // Processor Family MSRs
-  //
-  if (FamilyId == 0x06) {
-if (ModelId == 0x17 || ModelId == 0x0f) {
-  mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE;
-  mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK;
-}
-  }
-
-  //
-  // Intel(R) 64 and I

[edk2] [PATCH v5 25/33] OvmfPkg: use relaxed AP SMM synchronization mode

2015-11-26 Thread Laszlo Ersek
From: Paolo Bonzini 

Port 0xb2 on QEMU only sends an SMI to the currently executing processor.
The SMI handler, however, and in particular SmmWaitForApArrival, currently
expects that SmmControl2DxeTrigger triggers an SMI IPI on all processors
rather than just the BSP.  Thus all SMM invocations loop for a second (the
default value of PcdCpuSmmApSyncTimeout) before SmmWaitForApArrival sends
another SMI IPI to the APs.

With the default SmmCpuFeaturesLib, 32-bit machines must broadcast SMIs
because 32-bit machines must reset the MTRRs on each entry to system
management modes (they have no SMRRs).  However, our virtual platform
does not have problems with cacheability of SMRAM, so we can use "directed"
SMIs instead.  To do this, just set gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode
to 1 (aka SmmCpuSyncModeRelaxedAp).  This fixes SMM on multiprocessor virtual
machines.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael Kinney 
---

Notes:
v3:
- new in v3

 OvmfPkg/OvmfPkgIa32.dsc| 4 
 OvmfPkg/OvmfPkgIa32X64.dsc | 4 
 OvmfPkg/OvmfPkgX64.dsc | 4 
 3 files changed, 12 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index dd9f7b5..3a9292c 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -398,6 +398,10 @@ [PcdsFixedAtBuild]
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
 !endif
 
+!if $(SMM_REQUIRE) == TRUE
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
+!endif
+
 !if $(SECURE_BOOT_ENABLE) == TRUE
   # override the default values from SecurityPkg to ensure images from all 
sources are verified in secure boot
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 4d5943b..89e0b88 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -404,6 +404,10 @@ [PcdsFixedAtBuild]
 !endif
 
 [PcdsFixedAtBuild.X64]
+!if $(SMM_REQUIRE) == TRUE
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
+!endif
+
 !if $(SECURE_BOOT_ENABLE) == TRUE
   # override the default values from SecurityPkg to ensure images from all 
sources are verified in secure boot
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index da041a6..96faf52 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -403,6 +403,10 @@ [PcdsFixedAtBuild]
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
 !endif
 
+!if $(SMM_REQUIRE) == TRUE
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
+!endif
+
 !if $(SECURE_BOOT_ENABLE) == TRUE
   # override the default values from SecurityPkg to ensure images from all 
sources are verified in secure boot
   gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
-- 
1.8.3.1


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


Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

2015-11-26 Thread Yao, Jiewen
Comments below:

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Friday, November 27, 2015 9:59 AM
To: Yao, Jiewen; Kinney, Michael D; edk2-de...@ml01.01.org
Cc: Paolo Bonzini; Fan, Jeff
Subject: Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

On 11/27/15 02:14, Yao, Jiewen wrote:
> Hi Laszlo
> Comments below:
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Laszlo Ersek
> Sent: Friday, November 27, 2015 5:57 AM
> To: Yao, Jiewen; Kinney, Michael D; edk2-de...@ml01.01.org
> Cc: Paolo Bonzini; Fan, Jeff
> Subject: Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
> 
> On 11/25/15 22:56, Yao, Jiewen wrote:
>> Hi Mike
>> Thanks for the suggestion.
>> Previously, I just want to *ADD* without touch old logic. I will use your 
>> way to do it.
>>
>> -Original Message-
>> From: Kinney, Michael D
>> Sent: Thursday, November 26, 2015 2:01 AM
>> To: Yao, Jiewen; edk2-de...@ml01.01.org; Kinney, Michael D
>> Cc: Fan, Jeff
>> Subject: RE: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
>>
>> Jiewen,
>>
>> For IA32 assembly, can we combine into a single OR instruction that sets 
>> both page enable and WP?
>> For X64, does it make sense to use single OR instruction instead of 2 BTS 
>> instructions as well?
>>
>> With those updates,
>>
>> Reviewed-by: Michael Kinney 
>>
>> Thanks,
>>
>> Mike
>>
>>> -Original Message-
>>> From: Yao, Jiewen
>>> Sent: Wednesday, November 25, 2015 4:35 AM
>>> To: edk2-de...@ml01.01.org
>>> Cc: Yao, Jiewen ; Fan, Jeff 
>>> ; Kinney, Michael D 
>>> Subject: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
>>>
>>> So that we can use write-protection for code later.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: "Yao, Jiewen" 
>>> Cc: "Fan, Jeff" 
>>> Cc: "Kinney, Michael D" 
>>> ---
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S   | 1 +
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 1 +
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S| 1 +
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm  | 1 +
>>>  4 files changed, 4 insertions(+)
>>>
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> index 7e1787c..8e64ce8 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> @@ -142,6 +142,7 @@ L13:
>>>
>>>  movl%cr0, %ebx
>>>  orl $0x08000, %ebx # enable paging
>>> +orl $0x1, %ebx # set WP
>>>  movl%ebx, %cr0
>>>  lealDSC_OFFSET(%edi),%ebx
>>>  movwDSC_DS(%ebx),%ax
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> index e6af344..a955785 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> @@ -148,6 +148,7 @@ gSmiCr3 DD  ?
>>>
>>>  mov ebx, cr0
>>>  or  ebx, 08000h ; enable paging
>>> +or  ebx, 1h ; set WP
>>>  mov cr0, ebx
>>>  lea ebx, [edi + DSC_OFFSET]
>>>  mov ax, [ebx + DSC_DS]
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> index 1d40819..8050a00 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> @@ -163,6 +163,7 @@ NxeDone:
>>>  wrmsr
>>>  movq%cr0, %rbx
>>>  btsl$31, %ebx
>>> +btsl$16, %ebx   # set WP
>>>  movq%rbx, %cr0
>>>  retf
>>>  LongMode:   # long mode (64-bit code) starts 
>>> here
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> index 6e1d3f1..db170d6 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> @@ -159,6 +159,7 @@ Base:
>>>  wrmsr
>>>  mov rbx, cr0
>>>  bts ebx, 31
>>> +bts ebx, 16; set WP
>>>  mov cr0, rbx
>>>  retf
>>>  @LongMode:  ; long mode (64-bit code) starts 
>>> here
>>> --
>>> 1.9.5.msysgit.0
> 
> This patch (= SVN r18960) breaks the 32-bit (Ia32) build of the OVMF SMM 
> series.
> 
> KVM "rejects" the guest soon after the SMBASE relocation.
> 
> These are the last messages from the OVMF debug log:
> 
>> Loading SMM driver at 0x0007FFD2000 EntryPoint=0x0007FFD2253 
>> PiSmmCpuDxeSmm.efi SMRR Base: 0x7F80, SMRR Size: 0x80 
>> PcdCpuSmmCodeAccessCheckEnable = 1 SMRAM TileSize = 0x2000 
>> (0x1000, 0x1000) SMRAM SaveState Buffer (0x7FFC4000,
>> 0xE000) CPU[000]  APIC ID=  SMBASE=7FFBC000
>> SaveState=7FFCBC00  Size=0400 CPU[001]  APIC ID=0002
>> SMBASE=7FFBE000  SaveState=7FFCDC00  Size=0400 CPU[002]  APIC
>> ID=

[edk2] [PATCH v5 18/33] OvmfPkg: resolve DebugAgentLib for DXE_SMM_DRIVER modules

2015-11-26 Thread Laszlo Ersek
From: Michael Kinney 

Add mappings to DebugAgentLib for SMM modules to prevent build breaks when
SMM_REQUIRE and SOURCE_DEBUG_ENABLE are both set.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
[ler...@redhat.com: cover the X64 dsc, update commit msg, kudos Jordan]
Cc: Michael Kinney 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v3:
- new in v3

 OvmfPkg/OvmfPkgIa32.dsc| 3 +++
 OvmfPkg/OvmfPkgIa32X64.dsc | 3 +++
 OvmfPkg/OvmfPkgX64.dsc | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index f3de592..f229edf 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -309,6 +309,9 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
 !endif
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
+!endif
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index ee97c84..557c15f 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -314,6 +314,9 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
 !endif
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
+!endif
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 6ab7ffe..4b6e6db 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -314,6 +314,9 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
 !endif
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+!ifdef $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
+!endif
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-- 
1.8.3.1


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


[edk2] [PATCH v5 31/33] OvmfPkg: consolidate variable driver stack in DSC and FDF files

2015-11-26 Thread Laszlo Ersek
The following modules constitute the variable driver stack:

- QemuFlashFvbServicesRuntimeDxe and EmuVariableFvbRuntimeDxe, runtime
  alternatives for providing the Firmware Volume Block(2) Protocol,
  dependent on qemu pflash presence,

- FaultTolerantWriteDxe, providing the Fault Tolerant Write Protocol,

- MdeModulePkg/Universal/Variable/RuntimeDxe, independently of
  -D SECURE_BOOT_ENABLE, providing the Variable and Variable Write
  Architectural Protocols.

Let's move these drivers closer to each other in the DSC and FDF files, so
that we can switch the variable driver stack to SMM with more local
changes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/OvmfPkgIa32.dsc| 24 
 OvmfPkg/OvmfPkgIa32X64.dsc | 24 
 OvmfPkg/OvmfPkgX64.dsc | 24 
 OvmfPkg/OvmfPkgIa32.fdf| 12 ++
 OvmfPkg/OvmfPkgIa32X64.fdf | 12 ++
 OvmfPkg/OvmfPkgX64.fdf | 12 ++
 6 files changed, 66 insertions(+), 42 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index a8a1107..46a057a 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -542,19 +542,9 @@ [Components]
   OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
   OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
-  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
-
-  PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
-  }
-  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
-
-  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
-  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
@@ -742,3 +732,17 @@ [Components]
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   }
 !endif
+
+  #
+  # Variable driver stack
+  #
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
+
+  PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
+  }
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index d873043..2f2ec05 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -549,19 +549,9 @@ [Components.X64]
   OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
   OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
-  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
-
-  PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
-  }
-  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
-
-  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
-  }
   MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
@@ -749,3 +739,17 @@ [Components.X64]
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   }
 !endif
+
+  #
+  # Variable driver stack
+  #
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
+
+  PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
+  }
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 9f3168f..f0b6d6e 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -547,19 +547,9 @@ [Components]
   OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
   OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
-  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf
-  OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
-
-  PlatformF

[edk2] [PATCH v5 01/33] OvmfPkg: introduce -D SMM_REQUIRE and PcdSmmSmramRequire

2015-11-26 Thread Laszlo Ersek
This build time flag and corresponding Feature PCD will control whether
OVMF supports (and, equivalently, requires) SMM/SMRAM support from QEMU.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/OvmfPkg.dec| 10 ++
 OvmfPkg/OvmfPkgIa32.dsc|  4 
 OvmfPkg/OvmfPkgIa32X64.dsc |  4 
 OvmfPkg/OvmfPkgX64.dsc |  4 
 4 files changed, 22 insertions(+)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index d79aff4..f9decd3 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -121,3 +121,13 @@ [PcdsFeatureFlag]
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d
+
+  ## This feature flag enables SMM/SMRAM support. Note that it also requires
+  #  such support from the underlying QEMU instance; if that support is not
+  #  present, the firmware will reject continuing after a certain point.
+  #
+  #  The flag also acts as a general "security switch"; when TRUE, many
+  #  components will change behavior, with the goal of preventing a malicious
+  #  runtime OS from tampering with firmware structures (special memory ranges
+  #  used by OVMF, the varstore pflash chip, LockBox etc).
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 0d044c2..c6850ff 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -36,6 +36,7 @@ [Defines]
   DEFINE SECURE_BOOT_ENABLE  = FALSE
   DEFINE NETWORK_IP6_ENABLE  = FALSE
   DEFINE HTTP_BOOT_ENABLE= FALSE
+  DEFINE SMM_REQUIRE = FALSE
 
 [BuildOptions]
   GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
@@ -311,6 +312,9 @@ [PcdsFeatureFlag]
 !if $(SECURE_BOOT_ENABLE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
 !endif
+!if $(SMM_REQUIRE) == TRUE
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
+!endif
 
 [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 19d2221..dd65bf9 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -36,6 +36,7 @@ [Defines]
   DEFINE SECURE_BOOT_ENABLE  = FALSE
   DEFINE NETWORK_IP6_ENABLE  = FALSE
   DEFINE HTTP_BOOT_ENABLE= FALSE
+  DEFINE SMM_REQUIRE = FALSE
 
 [BuildOptions]
   GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
@@ -316,6 +317,9 @@ [PcdsFeatureFlag]
 !if $(SECURE_BOOT_ENABLE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
 !endif
+!if $(SMM_REQUIRE) == TRUE
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
+!endif
 
 [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index b8df1dc..0de3c85 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -36,6 +36,7 @@ [Defines]
   DEFINE SECURE_BOOT_ENABLE  = FALSE
   DEFINE NETWORK_IP6_ENABLE  = FALSE
   DEFINE HTTP_BOOT_ENABLE= FALSE
+  DEFINE SMM_REQUIRE = FALSE
 
 [BuildOptions]
   GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
@@ -316,6 +317,9 @@ [PcdsFeatureFlag]
 !if $(SECURE_BOOT_ENABLE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|TRUE
 !endif
+!if $(SMM_REQUIRE) == TRUE
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
+!endif
 
 [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
-- 
1.8.3.1


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


[edk2] [PATCH v5 06/33] OvmfPkg: PlatformPei: account for TSEG size with PcdSmmSmramRequire set

2015-11-26 Thread Laszlo Ersek
PlatformPei calls GetSystemMemorySizeBelow4gb() in three locations:

- PublishPeiMemory(): on normal boot, the permanent PEI RAM is installed
  so that it ends with the RAM below 4GB,

- QemuInitializeRam(): on normal boot, memory resource descriptor HOBs are
  created for the RAM below 4GB; plus MTRR attributes are set
  (independently of S3 vs. normal boot)

- MemMapInitialization(): an MMIO resource descriptor HOB is created for
  PCI resource allocation, on normal boot, starting at max(RAM below 4GB,
  2GB).

The first two of these is adjusted for the configured TSEG size, if
PcdSmmSmramRequire is set:

- In PublishPeiMemory(), the permanent PEI RAM is kept under TSEG.

- In QemuInitializeRam(), we must keep the DXE out of TSEG.

  One idea would be to simply trim the [1MB .. LowerMemorySize] memory
  resource descriptor HOB, leaving a hole for TSEG in the memory space
  map.

  The SMM IPL will however want to massage the caching attributes of the
  SMRAM range that it loads the SMM core into, with
  gDS->SetMemorySpaceAttributes(), and that won't work on a hole. So,
  instead of trimming this range, split the TSEG area off, and report it
  as a cacheable reserved memory resource.

  Finally, since reserved memory can be allocated too, pre-allocate TSEG
  in InitializeRamRegions(), after QemuInitializeRam() returns. (Note that
  this step alone does not suffice without the resource descriptor HOB
  trickery: if we omit that, then the DXE IPL PEIM fails to load and start
  the DXE core.)

- In MemMapInitialization(), the start of the PCI MMIO range is not
  affected.

We choose the largest option (8MB) for the default TSEG size. Michael
Kinney pointed out that the SMBASE relocation in PiSmmCpuDxeSmm consumes
SMRAM proportionally to the number of CPUs. From the three options
available, he reported that 8MB was both necessary and sufficient for the
SMBASE relocation to succeed with 255 CPUs:

- http://thread.gmane.org/gmane.comp.bios.edk2.devel/3020/focus=3137
- http://thread.gmane.org/gmane.comp.bios.edk2.devel/3020/focus=3177

Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
Reviewed-by: Michael Kinney 
---

Notes:
v4:
- drop the patch "OvmfPkg: double the SMRAM (TSEG) size for the 64-bit
  DXE phase builds", and change the default TSEG size from 1MB to 8MB
  globally [Mike]

 OvmfPkg/OvmfPkg.dec |  7 
 OvmfPkg/PlatformPei/PlatformPei.inf |  1 +
 OvmfPkg/PlatformPei/MemDetect.c | 34 +++-
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 3fab2af..04859b4 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -93,6 +93,13 @@ [PcdsFixedAtBuild]
   gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6
   gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7
 
+  ## The following setting controls how many megabytes we configure as TSEG on
+  #  Q35, for SMRAM purposes. Permitted values are: 1, 2, 8. Other values cause
+  #  undefined behavior.
+  #
+  #  This PCD is only consulted if PcdSmmSmramRequire is TRUE (see below).
+  gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8|UINT8|0x20
+
 [PcdsFixedAtBuild]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase|0x0|UINT32|0x8
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize|0x0|UINT32|0x9
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf 
b/OvmfPkg/PlatformPei/PlatformPei.inf
index 62f64fe..ee044a2 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -75,6 +75,7 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
+  gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
   gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 5fe8b28..1bdc2df 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -214,6 +214,12 @@ PublishPeiMemory (
 MemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);
   } else {
 LowerMemorySize = GetSystemMemorySizeBelow4gb ();
+if (FeaturePcdGet (PcdSmmSmramRequire)) {
+  //
+  // TSEG is chipped from the end of low RAM
+  //
+  LowerMemorySize -= FixedPcdGet8 (PcdQ35TsegMbytes) * SIZE_1MB;
+}
 
 PeiMemoryCap = GetPeiMemoryCap ();
 DEBUG ((EFI_D_INFO, "%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
@@ -277,7 +283,18 @@ QemuInitializeRam (
 // Create memory HOBs
 //
 AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
-AddMemoryRangeHob (BASE_1MB, LowerMemorySize);
+
+if (FeaturePcdGet (PcdSmmSmramRequire)) {
+  UINT32 

[edk2] [PATCH v5 29/33] OvmfPkg: QemuFlashFvbServicesRuntimeDxe: add DXE_SMM_DRIVER build

2015-11-26 Thread Laszlo Ersek
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf  | 89 

 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c | 66 +++
 2 files changed, 155 insertions(+)

diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
new file mode 100644
index 000..6af0649
--- /dev/null
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
@@ -0,0 +1,89 @@
+## @file
+#  Component description file for QEMU Flash Fimware Volume Block SMM driver
+#  module.
+#
+#  This SMM driver implements and produces the SMM Fimware Volue Block Protocol
+#  for a QEMU flash device.
+#
+#  Copyright (C) 2015, Red Hat, Inc.
+#  Copyright (c) 2006 - 2013, 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = FvbServicesSmm
+  FILE_GUID  = 2E7DB7A7-608E-4041-B45F-00359E0766C6
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_VERSION   = 0x0001000A
+  ENTRY_POINT= FvbInitialize
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  FvbInfo.c
+  FwBlockService.c
+  FwBlockServiceSmm.c
+  QemuFlash.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  DevicePathLib
+  DxeServicesTableLib
+  MemoryAllocationLib
+  PcdLib
+  SmmServicesTableLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Guids]
+
+[Protocols]
+  gEfiSmmFirmwareVolumeBlockProtocolGuid# PROTOCOL ALWAYS_PRODUCED
+  gEfiDevicePathProtocolGuid# PROTOCOL ALWAYS_PRODUCED
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareBlockSize
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
+
+
+[Depex]
+  TRUE
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
new file mode 100644
index 000..e77129e
--- /dev/null
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
@@ -0,0 +1,66 @@
+/**@file
+  Functions related to the Firmware Volume Block service whose
+  implementation is specific to the SMM driver build.
+
+  Copyright (C) 2015, Red Hat, Inc.
+  Copyright (c) 2006 - 2014, 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.
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+#include "FwBlockService.h"
+
+VOID
+InstallProtocolInterfaces (
+  IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
+  )
+{
+  EFI_HANDLE FvbHandle;
+  EFI_STATUS Status;
+
+  //
+  // There is no SMM service that can install multiple protocols in the SMM
+  // protocol database in one go.
+  //
+  // The SMM Firmware Volume Block protocol structure is the same as the
+  // Firmware Volume Block protocol structure.
+  //
+  FvbHandle = NULL;
+  DEBUG ((EFI_D_INFO, "Installing QEMU flash SMM FVB\n"));
+  Status = gSmst->SmmInstallProt

[edk2] [PATCH v5 09/33] OvmfPkg: implement EFI_SMM_CONTROL2_PROTOCOL with a DXE_RUNTIME_DRIVER

2015-11-26 Thread Laszlo Ersek
The EFI_SMM_COMMUNICATION_PROTOCOL implementation that is provided by the
SMM core depends on EFI_SMM_CONTROL2_PROTOCOL; see the
mSmmControl2->Trigger() call in the SmmCommunicationCommunicate() function
[MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c].

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael Kinney 
---

Notes:
v5:
- Move forward declaration of OnS3SaveStateInstalled() before globals
  and function implementations [Mike]
- Correct SOMETIMES_CONSUMES and PRODUCES comments on the protocol GUIDs
  in the INF file [Mike]
- replace _ASSERT (FALSE) with ASSERT (FALSE) + CpuDeadLoop () [Mike]

v2:
- Set (APMC_EN|GBL_SMI_EN) in SMI_EN from the boot script at S3 resume.
  Otherwise, because SMI_EN is cleared during warm reset,
  SmmControl2DxeTrigger() would fail to trigger an SMI, and variable
  access through the runtime services would fail.

  Set SMI_LOCK in GEN_PMCON_1 similarly.

 OvmfPkg/OvmfPkgIa32.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   1 +
 OvmfPkg/OvmfPkgX64.dsc|   1 +
 OvmfPkg/OvmfPkgIa32.fdf   |   1 +
 OvmfPkg/OvmfPkgIa32X64.fdf|   1 +
 OvmfPkg/OvmfPkgX64.fdf|   1 +
 OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf |  66 
 OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.c   | 366 
 8 files changed, 438 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index d7bc38d..c71a2f4 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -675,4 +675,5 @@ [Components]
 
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index e17cbe5..a1e8f0d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -682,4 +682,5 @@ [Components.X64]
 
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index a748fb3..1176629 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -680,4 +680,5 @@ [Components]
 
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 285720f..43c9c30 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -357,6 +357,7 @@ [FV.DXEFV]
 
 !if $(SMM_REQUIRE) == TRUE
 INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 !endif
 
 

diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 02e8752..9446896 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -357,6 +357,7 @@ [FV.DXEFV]
 
 !if $(SMM_REQUIRE) == TRUE
 INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 !endif
 
 

diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index f04c36b..b272b76 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -357,6 +357,7 @@ [FV.DXEFV]
 
 !if $(SMM_REQUIRE) == TRUE
 INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 !endif
 
 

diff --git a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf 
b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
new file mode 100644
index 000..0e9f98c
--- /dev/null
+++ b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
@@ -0,0 +1,66 @@
+## @file
+# A DXE_RUNTIME_DRIVER providing synchronous SMI activations via the
+# EFI_SMM_CONTROL2_PROTOCOL.
+#
+# We expect the PEI phase to have covered the following:
+# - ensure that the underlying QEMU machine type be Q35
+#   (responsible: OvmfPkg/SmmAccess/SmmAccessPei.inf)
+# - ensure that the ACPI PM IO space be configured
+#   (responsible: OvmfPkg/PlatformPei/PlatformPei.inf)
+#
+# Our own entry point is responsible for confirming the SMI feature and for
+# configuring it.
+#
+# Copyright (C) 2013, 2015, Red Hat, Inc.
+#
+# 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SmmControl2Dxe
+  FILE_GUID  = 1206F7CA-A475-4624-A83E-E6FC9BB38E49
+  MODULE_TYPE

[edk2] [PATCH v5 30/33] OvmfPkg: QemuFlashFvbServicesRuntimeDxe: adhere to -D SMM_REQUIRE

2015-11-26 Thread Laszlo Ersek
When the user requires "security" by passing -D SMM_REQUIRE, and
consequently by setting PcdSmmSmramRequire, enforce flash-based variables.

Furthermore, add two ASSERT()s to catch if the wrong module were pulled
into the build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf | 2 ++
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf| 2 ++
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c   | 3 +++
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c   | 3 +++
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c   | 1 +
 5 files changed, 11 insertions(+)

diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
index ea8413f..c0dda75 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
@@ -85,6 +85,8 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
 
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
 
 [Depex]
   TRUE
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
index 6af0649..ba2d367 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
@@ -84,6 +84,8 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
 
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
 
 [Depex]
   TRUE
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
index c11f598..63b3086 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,6 +35,8 @@ InstallProtocolInterfaces (
   EFI_HANDLE FwbHandle;
   EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
 
+  ASSERT (!FeaturePcdGet (PcdSmmSmramRequire));
+
   //
   // Find a handle with a matching device path that has supports FW Block
   // protocol
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
index e77129e..e0617f2 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c
@@ -15,6 +15,7 @@
 **/
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +30,8 @@ InstallProtocolInterfaces (
   EFI_HANDLE FvbHandle;
   EFI_STATUS Status;
 
+  ASSERT (FeaturePcdGet (PcdSmmSmramRequire));
+
   //
   // There is no SMM service that can install multiple protocols in the SMM
   // protocol database in one go.
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
index 28bcb13..5677b5e 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
@@ -245,6 +245,7 @@ QemuFlashInitialize (
   mFdBlockCount = PcdGet32 (PcdOvmfFirmwareFdSize) / mFdBlockSize;
 
   if (!QemuFlashDetected ()) {
+ASSERT (!FeaturePcdGet (PcdSmmSmramRequire));
 return EFI_WRITE_PROTECTED;
   }
 
-- 
1.8.3.1


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


[edk2] [PATCH v5 33/33] OvmfPkg: README: document SMM status

2015-11-26 Thread Laszlo Ersek
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v5:
- extract Linux and QEMU requirements at the top of the SMM section
  [Jordan]
- add note about line continuation characters ('\' and '^') [Jordan]
- add '$' command prompts for signaling command line starts [Jordan]
- change the wording around the "ICH9-LPC.disable_s3" flag to clarify
  that QEMU enables S3 by default

v4:
- update to current test results

v3:
- this documentation is not accurate any longer, but since Paolo and
  myself are getting different test results, I'm not bothering updating
  this until our results converge

v2:
- documented "-nx" VCPU feature flag
  

 OvmfPkg/README | 57 
 1 file changed, 57 insertions(+)

diff --git a/OvmfPkg/README b/OvmfPkg/README
index 147e6e0..0f70fa7 100644
--- a/OvmfPkg/README
+++ b/OvmfPkg/README
@@ -118,6 +118,63 @@ $ OvmfPkg/build.sh -a X64 qemu -cdrom 
/path/to/disk-image.iso
 To build a 32-bit OVMF without debug messages using GCC 4.5:
 $ OvmfPkg/build.sh -a IA32 -b RELEASE -t GCC45
 
+=== SMM support ===
+
+Requirements:
+* SMM support requires QEMU 2.5.
+* The minimum required QEMU machine type is "pc-q35-2.5".
+* SMM with KVM requires Linux 4.4 (host).
+
+OVMF is capable of utilizing SMM if the underlying QEMU or KVM hypervisor
+emulates SMM. SMM is put to use in the S3 suspend and resume infrastructure,
+and in the UEFI variable driver stack. The purpose is (virtual) hardware
+separation between the runtime guest OS and the firmware (OVMF), with the
+intent to make Secure Boot actually secure, by preventing the runtime guest OS
+from tampering with the variable store and S3 areas.
+
+For SMM support, OVMF must be built with the "-D SMM_REQUIRE" option. The
+resultant firmware binary will check if QEMU actually provides SMM emulation;
+if it doesn't, then OVMF will log an error and trigger an assertion failure
+during boot (even in RELEASE builds). Both the naming of the flag (SMM_REQUIRE,
+instead of SMM_ENABLE), and this behavior are consistent with the goal
+described above: this is supposed to be a security feature, and fallbacks are
+not allowed. Similarly, a pflash-backed variable store is a requirement.
+
+QEMU should be started with the options listed below (in addition to any other
+guest-specific flags). The command line should be gradually composed from the
+hints below. '\' is used to extend the command line to multiple lines, and '^'
+can be used on Windows.
+
+* QEMU binary and options specific to 32-bit guests:
+
+  $ qemu-system-i386 -cpu coreduo,-nx \
+
+  or
+
+  $ qemu-system-x86_64 -cpu ,-lm,-nx \
+
+* QEMU binary for running 64-bit guests (no particular options):
+
+  $ qemu-system-x86_64 \
+
+* Flags common to all SMM scenarios (only the Q35 machine type is supported):
+
+  -machine q35,smm=on,accel=(tcg|kvm) \
+  -m ... \
+  -smp ... \
+  -global driver=cfi.pflash01,property=secure,value=on \
+  -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on \
+  -drive if=pflash,format=raw,unit=1,file=copy_of_OVMF_VARS.fd \
+
+* In order to disable S3, add:
+
+  -global ICH9-LPC.disable_s3=1 \
+
+Dependent on the development status of the
+"UefiCpuPkg/Universal/Acpi/S3Resume2Pei" module, S3 resume may not work in
+OvmfPkg/OvmfPkgX64.dsc builds. In such cases, OvmfPkg/OvmfPkgIa32X64.dsc is
+recommended for running X64 guests.
+
 === Network Support ===
 
 OVMF provides a UEFI network stack by default. Its lowest level driver is the
-- 
1.8.3.1

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


[edk2] [PATCH v5 26/33] OvmfPkg: any AP in SMM should not wait for the BSP for more than 100 ms

2015-11-26 Thread Laszlo Ersek
This patch complements the previous one, "OvmfPkg: use relaxed AP SMM
synchronization mode". While that patch focuses on the case when the SMI
is raised synchronously by the BSP, on the BSP:

  BSPHandler() [UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c]
SmmWaitForApArrival()  [UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c]
  IsSyncTimerTimeout() [UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c]

this patch concerns itself with the case when it is one of the APs that
raises (and sees delivered) the synchronous SMI:

  APHandler()[UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c]
IsSyncTimerTimeout() [UefiCpuPkg/PiSmmCpuDxeSmm/SyncTimer.c]

Namely, in APHandler() the AP waits for the BSP to enter SMM regardless of
PcdCpuSmmSyncMode, for PcdCpuSmmApSyncTimeout microseconds (the default
value is 1 second). If the BSP doesn't show up in SMM within that
interval, then the AP brings it in with a directed SMI, and waits for the
BSP again for PcdCpuSmmApSyncTimeout microseconds.

Although during boot services, SmmControl2DxeTrigger() is only called by
the BSP, at runtime the OS can invoke runtime services from an AP (it can
even be forced with "taskset -c 1 efibootmgr"). Because on QEMU
SmmControl2DxeTrigger() only raises the SMI for the calling processor (BSP
and AP alike), the first interval above times out invariably in such cases
-- the BSP never shows up before the AP calls it in.

In order to mitigate the performance penalty, decrease
PcdCpuSmmApSyncTimeout to one tenth of its default value: 100 ms. (For
comparison, Vlv2TbltDevicePkg sets 1 ms.)

NOTE: once QEMU becomes capable of synchronous broadcast SMIs, this patch
and the previous one ("OvmfPkg: use relaxed AP SMM synchronization mode")
should be reverted, and SmmControl2DxeTrigger() should be adjusted
instead.

Cc: Paolo Bonzini 
Cc: Jordan Justen 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael Kinney 
---

Notes:
v4:
- new in v4

 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 3a9292c..485966a 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -400,6 +400,7 @@ [PcdsFixedAtBuild]
 
 !if $(SMM_REQUIRE) == TRUE
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|10
 !endif
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 89e0b88..bd76303 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -406,6 +406,7 @@ [PcdsFixedAtBuild]
 [PcdsFixedAtBuild.X64]
 !if $(SMM_REQUIRE) == TRUE
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|10
 !endif
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 96faf52..653f2a1 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -405,6 +405,7 @@ [PcdsFixedAtBuild]
 
 !if $(SMM_REQUIRE) == TRUE
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|10
 !endif
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
-- 
1.8.3.1


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


[edk2] [PATCH v5 12/33] OvmfPkg: AcpiS3SaveDxe: don't fake LockBox protocol if SMM_REQUIRE

2015-11-26 Thread Laszlo Ersek
In SVN r15306 (git commit d4ba06df), "OvmfPkg: S3 Resume: fake LockBox
protocol for BootScriptExecutorDxe", we installed a fake LockBox protocol
in OVMF's AcpiS3SaveDxe clone. While our other AcpiS3SaveDxe
customizations remain valid (or harmless), said change is invalid when
OVMF is built with -D SMM_REQUIRE and includes the real protocol provider,
"MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Paolo Bonzini 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf |  3 ++-
 OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c  | 14 --
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf 
b/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
index 4cc0713..a288b95 100644
--- a/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
+++ b/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
@@ -59,7 +59,7 @@ [Guids]
   gEfiEndOfDxeEventGroupGuid## CONSUMES  ## Event
 
 [Protocols]
-  gEfiLockBoxProtocolGuid   # PROTOCOL ALWAYS_PRODUCED
+  gEfiLockBoxProtocolGuid   # PROTOCOL SOMETIMES_PRODUCED
   gEfiLegacyBiosProtocolGuid# PROTOCOL ALWAYS_CONSUMED
   gEfiLegacyRegion2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
   gFrameworkEfiMpServiceProtocolGuid# PROTOCOL SOMETIMES_CONSUMED
@@ -71,6 +71,7 @@ [Pcd]
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize## 
CONSUMES
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3BootScriptStackSize   ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire## 
CONSUMES
 
 [Depex]
   gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
diff --git a/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c 
b/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
index f20560f..e3ff234 100644
--- a/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
+++ b/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
@@ -538,12 +538,14 @@ InstallEndOfDxeCallback (
 return EFI_LOAD_ERROR;
   }
 
-  Status = gBS->InstallMultipleProtocolInterfaces (
-  &ImageHandle,
-  &gEfiLockBoxProtocolGuid, NULL,
-  NULL
-  );
-  ASSERT_EFI_ERROR (Status);
+  if (!FeaturePcdGet (PcdSmmSmramRequire)) {
+Status = gBS->InstallMultipleProtocolInterfaces (
+&ImageHandle,
+&gEfiLockBoxProtocolGuid, NULL,
+NULL
+);
+ASSERT_EFI_ERROR (Status);
+  }
 
   Status = gBS->CreateEventEx (
   EVT_NOTIFY_SIGNAL,
-- 
1.8.3.1


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


[edk2] [PATCH v5 03/33] OvmfPkg: Sec: assert the build-time calculated end of the scratch buffer

2015-11-26 Thread Laszlo Ersek
The DecompressMemFvs() function in "OvmfPkg/Sec/SecMain.c" uses more
memory, temporarily, than what PEIFV and DXEFV will ultimately need.
First, it uses an output buffer for decompression, second, the
decompression itself needs a scratch buffer (and this scratch buffer is
the highest area that SEC uses).

DecompressMemFvs() used to be called on normal boots only (ie. not on S3
resume), which is why the decompression output buffer and the scratch
buffer were allowed to scribble over RAM. However, we'll soon start to
worry during S3 resume that the runtime OS might tamper with the
pre-decompressed PEIFV, and we'll decompress the firmware volumes on S3
resume too, from pristine flash. For this we'll need to know the end of
the scratch buffer in advance, so we can prepare a non-malicious OS for
it.

Calculate the end of the scratch buffer statically in the FDF files, and
assert in DecompressMemFvs() that the runtime decompression will match it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v2:
- PcdOvmfDecomprScratchEnd => PcdOvmfDecompressionScratchEnd [Jordan]
  
- SCRATCH => DECOMP_SCRATCH [Jordan]
  (same)

 OvmfPkg/OvmfPkg.dec   |  1 +
 OvmfPkg/OvmfPkgIa32.fdf   |  4 +-
 OvmfPkg/OvmfPkgIa32X64.fdf|  4 +-
 OvmfPkg/OvmfPkgX64.fdf|  4 +-
 OvmfPkg/Sec/SecMain.inf   |  1 +
 OvmfPkg/Sec/SecMain.c |  8 +++
 OvmfPkg/DecomprScratchEnd.fdf.inc | 72 
 OvmfPkg/OvmfPkg.fdf.inc   |  2 +
 8 files changed, 93 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index f9decd3..3fab2af 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -110,6 +110,7 @@ [PcdsFixedAtBuild]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|0x0|UINT32|0x18
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize|0x0|UINT32|0x19
   gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize|0x0|UINT32|0x1a
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd|0x0|UINT32|0x1f
 
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 2581fdb..44e4a92 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -78,7 +78,7 @@ [FD.OVMF_CODE]
 

 
 [FD.MEMFD]
-BaseAddress   = 0x80
+BaseAddress   = $(MEMFD_BASE_ADDRESS)
 Size  = 0xA0
 ErasePolarity = 1
 BlockSize = 0x1
@@ -384,6 +384,8 @@ [FV.FVMAIN_COMPACT]
}
  }
 
+!include DecomprScratchEnd.fdf.inc
+
 

 
 [Rule.Common.SEC]
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 01f384a..67bfbe7 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -78,7 +78,7 @@ [FD.OVMF_CODE]
 

 
 [FD.MEMFD]
-BaseAddress   = 0x80
+BaseAddress   = $(MEMFD_BASE_ADDRESS)
 Size  = 0xA0
 ErasePolarity = 1
 BlockSize = 0x1
@@ -384,6 +384,8 @@ [FV.FVMAIN_COMPACT]
}
  }
 
+!include DecomprScratchEnd.fdf.inc
+
 

 
 [Rule.Common.SEC]
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 4ad89fb..6624789 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -78,7 +78,7 @@ [FD.OVMF_CODE]
 

 
 [FD.MEMFD]
-BaseAddress   = 0x80
+BaseAddress   = $(MEMFD_BASE_ADDRESS)
 Size  = 0xA0
 ErasePolarity = 1
 BlockSize = 0x1
@@ -384,6 +384,8 @@ [FV.FVMAIN_COMPACT]
}
  }
 
+!include DecomprScratchEnd.fdf.inc
+
 

 
 [Rule.Common.SEC]
diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 415731c..9e8571d 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -70,3 +70,4 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
   gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
   gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 0cf127a..93e3594 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -362,6 +362,14 @@ DecompressMemFvs (
 
   OutputBuffer = (VOID*) ((UINT8*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase) + 
SIZE_1MB);
   ScratchBuffer = ALIGN_POINTER ((UINT8*) OutputBuffer + OutputBufferSize, 
SIZE_1MB);
+
+  DEBUG ((EFI_D_VERBOSE, "%a: OutputBuffer@%p+0x%x ScratchBuffer@%p+0x%x "
+"PcdOvmfDecompre

[edk2] [PATCH v5 19/33] OvmfPkg: select LocalApicLib instance with x2apic support

2015-11-26 Thread Laszlo Ersek
Although neither LocalApicLib instance is suitable for runtime DXE drivers
(because they access the APIC at the physical address retrieved from
either MSR_IA32_APIC_BASE_ADDRESS or PcdCpuLocalApicBaseAddress), they are
suitable for SMM drivers -- SMM drivers are not influenced by the runtime
OS's virtual address map.

PiSmmCpuDxeSmm links against LocalApicLib. 64-bit Linux guests tend to
enable x2apic mode even in simple VCPU configurations (e.g., 4 sockets, 1
core/socket, 1 thread/core):

  [0.028173] x2apic enabled

If PiSmmCpuDxeSmm was linked with the BaseXApicLib instance (i.e., with no
x2apic support), then the next runtime service call that is backed by an
SMM driver triggers the following ASSERT in BaseXApicLib (because the
latter notices that x2apic has been enabled, which it doesn't support):

  ASSERT .../UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c(263):
  ApicBaseMsr.Bits.Extd == 0

It is reasonable to give all LocalApicLib client modules in OVMF the same
level of x2apic support, hence resolve LocalApicLib globally to
BaseXApicX2ApicLib. This will not be conditional on -D SMM_REQUIRE,
because BaseXApicX2ApicLib is compatible with BaseXApicLib in any
environment where the latter can be used.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v5:
- select BaseXApicX2ApicLib unconditionally (that is, regardless of
  SMM_REQUIRE) [Paolo, Mike, Brian]

v4:
- new in v4

 OvmfPkg/OvmfPkgIa32.dsc| 2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc | 2 +-
 OvmfPkg/OvmfPkgX64.dsc | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index f229edf..72132c7 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -120,7 +120,7 @@ [LibraryClasses]
 !endif
 
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
-  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
+  LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 557c15f..2a0d2d4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -125,7 +125,7 @@ [LibraryClasses]
 !endif
 
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
-  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
+  LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 4b6e6db..2ac2b69 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -125,7 +125,7 @@ [LibraryClasses]
 !endif
 
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
-  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
+  LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
-- 
1.8.3.1


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


[edk2] [PATCH v5 17/33] OvmfPkg: resolve CpuExceptionHandlerLib for DXE_SMM_DRIVER modules

2015-11-26 Thread Laszlo Ersek
UefiCpuPkg/PiSmmCpuDxeSmm depends on this library (the
RegisterCpuInterruptHandler() function specifically) to set up its
specialized page fault handler (SmiPFHandler() -> DumpModuleInfoByIp()).
It doesn't hurt to resolve this library class for all DXE_SMM_DRIVER
modules.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v2:
- new in v2 (the CpuExceptionHandlerLib dependency  of PiSmmCpuDxeSmm is
  new in Mike's code, relative to Quark)

 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 6a93fd2..f3de592 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -308,6 +308,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 !else
   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
 !endif
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index dbaf8fb..ee97c84 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -313,6 +313,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 !else
   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
 !endif
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index a7efe52..6ab7ffe 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -313,6 +313,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 !else
   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
 !endif
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-- 
1.8.3.1


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


[edk2] [PATCH v5 32/33] OvmfPkg: pull in SMM-based variable driver stack

2015-11-26 Thread Laszlo Ersek
When -D SMM_REQUIRE is given, replace both
- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf and
- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
with
- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf.

The outermost (= runtime DXE driver) VariableSmmRuntimeDxe enters SMM, and
the rest:
- the privileged half of the variable driver, VariableSmm,
- the fault tolerant write driver, FaultTolerantWriteSmm,
- and the FVB driver, FvbServicesSmm,
work in SMM purely.

We also resolve the BaseCryptLib class for DXE_SMM_DRIVER modules, for the
authenticated VariableSmm driver's sake.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v2:
- hook VarCheckUefiLib into VariableSmm
  


 OvmfPkg/OvmfPkgIa32.dsc| 18 --
 OvmfPkg/OvmfPkgIa32X64.dsc | 18 --
 OvmfPkg/OvmfPkgX64.dsc | 18 --
 OvmfPkg/OvmfPkgIa32.fdf| 16 ++--
 OvmfPkg/OvmfPkgIa32X64.fdf | 16 ++--
 OvmfPkg/OvmfPkgX64.fdf | 16 ++--
 6 files changed, 90 insertions(+), 12 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 46a057a..1c6c852 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -312,6 +312,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 !ifdef $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
 !endif
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -731,10 +732,22 @@ [Components]
   
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   }
-!endif
 
   #
-  # Variable driver stack
+  # Variable driver stack (SMM)
+  #
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
+
+!else
+
+  #
+  # Variable driver stack (non-SMM)
   #
   OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
   OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
@@ -746,3 +759,4 @@ [Components]
 
   NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   }
+!endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 2f2ec05..1a2f2a4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -317,6 +317,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 !ifdef $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
 !endif
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -738,10 +739,22 @@ [Components.X64]
   
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   }
-!endif
 
   #
-  # Variable driver stack
+  # Variable driver stack (SMM)
+  #
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {
+
+  NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
+  }
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
+
+!else
+
+  #
+  # Variable driver stack (non-SMM)
   #
   OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
   OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
@@ -753,3 +766,4 @@ [Components.X64]
 
   NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
   }
+!endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index f0b6d6e..0bbbfa8 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -317,6 +317,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 !ifdef $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
 !endif
+  BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -736,10 +737,22 @@ [Components]
   
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   }
-!endif
 
   #
-  # Variable driver stack
+  # Variable driver stack (SMM)
+  #
+  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite

[edk2] [PATCH v5 27/33] OvmfPkg: build CpuS3DataDxe for -D SMM_REQUIRE

2015-11-26 Thread Laszlo Ersek
The PiSmmCpuDxeSmm driver from UefiCpuPkg depends on the ACPI_CPU_DATA
structure -- created by a platform- and CPU-specific driver -- in order to
support ACPI S3. The address of this structure is communicated through the
dynamic PCD PcdCpuS3DataAddress.

The "UefiCpuPkg/Include/AcpiCpuData.h" header file documents the fields of
this structure in detail.

The simple/generic "UefiCpuPkg/CpuS3DataDxe" driver creates and populates
the structure in a conformant way, and it co-operates well with
PiSmmCpuDxeSmm, for OVMF's purposes.

 PlatformBdsLib  CpuS3DataDxe PiSmmCpuDxeSmmS3ResumePei
 (DXE_DRIVER)(DXE_DRIVER) (DXE_SMM_DRIVER)  (PEIM)
 --  ---    --
normal   collects data
boot except MTRR
 settings into
 ACPI_CPU_DATA

 sets
 PcdCpuS3Da...

 signals
 End-of-Dxe
|
+--> collects MTRR
 settings into
 ACPI_CPU_DATA

 installs
 [Dxe]Smm
 ReadyToLock
|
+---> fetches
  PcdCpuS3Dat...

  copies
  ACPI_CPU_DATA
  into SMRAM

runtime

S3
suspend

S3  transfers
resume  control to
PiSmmCpuDxe...
|
  uses <+
  ACPI_CPU_DATA
  from SMRAM

Cc: Jordan Justen 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---

Notes:
v5:
- rename patch from
  "OvmfPkg: build QuarkPort/CpuS3DataDxe for -D SMM_REQUIRE"
- get driver from UefiCpuPkg, rather than OvmfPkg/QuarkPort
- incorporate data / control flow information in the commit message
  from:
  "OvmfPkg: add skeleton QuarkPort/CpuS3DataDxe"
  "OvmfPkg: QuarkPort/CpuS3DataDxe: fill in ACPI_CPU_DATA.MtrrTable"

v3:
- new in v3; split out from
  "OvmfPkg: add skeleton QuarkPort/CpuS3DataDxe".

 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 OvmfPkg/OvmfPkgIa32.fdf| 1 +
 OvmfPkg/OvmfPkgIa32X64.fdf | 1 +
 OvmfPkg/OvmfPkgX64.fdf | 1 +
 6 files changed, 6 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 485966a..5a63e5b 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -716,6 +716,7 @@ [Components]
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
   OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
 
   #
   # SMM Initial Program Load (a DXE_RUNTIME_DRIVER)
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index bd76303..b99a1c0 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -723,6 +723,7 @@ [Components.X64]
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
   OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
 
   #
   # SMM Initial Program Load (a DXE_RUNTIME_DRIVER)
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 653f2a1..cd52bda 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -721,6 +721,7 @@ [Components]
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
   OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
 
   #
   # SMM Initial Program Load (a DXE_RUNTIME_DRIVER)
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 53ddae3..83702a1 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -358,6 +358,7 @@ [FV.DXEFV]
 !if $(SMM_REQUIRE) == TRUE
 INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
 INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+INF  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index bb7ca6e..1af0c17 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -358,6 +358,7 @@ [FV.DXEFV]
 !if $(SMM_REQUIRE) == TRUE
 INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
 INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+INF  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm

[edk2] [PATCH v5 10/33] OvmfPkg: pull in the SMM IPL and SMM core

2015-11-26 Thread Laszlo Ersek
"MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf" (a DXE_RUNTIME_DRIVER)
implements the SMM Initial Program Loader. It produces
EFI_SMM_BASE2_PROTOCOL and EFI_SMM_COMMUNICATION_PROTOCOL, relying on:
- EFI_SMM_ACCESS2_PROTOCOL
  (provided by OvmfPkg/SmmAccess/SmmAccess2Dxe.inf),
- EFI_SMM_CONTROL2_PROTOCOL
  (provided by OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf).

(The SMM IPL also depends on EFI_SMM_CONFIGURATION_PROTOCOL_GUID, but this
dependency is not enforced in the entry point. A protocol notify callback
is registered instead, hence we can delay providing that protocol via the
PiSmmCpuDxeSmm driver that is (to be) imported from UefiCpuPkg/.)

The SMM IPL loads the SMM core into SMRAM and executes it from there.
Therefore we add the SMM core to the build as well.

For the SMM core, a number of library classes need to be resolved.
Furthermore, each FDF file must provide the GenFds.py BaseTools utility
with a build rule for SMM_CORE; we copy the DXE_CORE's rule.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v5:
- update the commit message to refer to UefiCpuPkg rather than to the
  Quark distribution as the location of PiSmmCpuDxeSmm

 OvmfPkg/OvmfPkgIa32.dsc| 21 
 OvmfPkg/OvmfPkgIa32X64.dsc | 21 
 OvmfPkg/OvmfPkgX64.dsc | 21 
 OvmfPkg/OvmfPkgIa32.fdf|  9 +
 OvmfPkg/OvmfPkgIa32X64.fdf |  9 +
 OvmfPkg/OvmfPkgX64.fdf |  9 +
 6 files changed, 90 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index c71a2f4..ca3be30 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -296,6 +296,17 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
+  
MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
+  
SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
 
 

 #
@@ -676,4 +687,14 @@ [Components]
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
   OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+
+  #
+  # SMM Initial Program Load (a DXE_RUNTIME_DRIVER)
+  #
+  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
+
+  #
+  # SMM_CORE
+  #
+  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a1e8f0d..60f085a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -301,6 +301,17 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf
+  
MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
+  
SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
 
 

 #
@@ -683,4 +694,14 @@ [Components.X64]
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
   OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
+
+  #
+  # SMM Initial Program Load (a DXE_RUNTIME_DRIVER)
+  #
+  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
+
+  #
+  # SMM_CORE
+  #
+  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 1176629..0621292 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -301,6 +301,17 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookL

[edk2] [PATCH v5 11/33] OvmfPkg: pull in CpuIo2Smm driver

2015-11-26 Thread Laszlo Ersek
This driver provides EFI_SMM_CPU_IO2_PROTOCOL, which the SMM core depends
on in its gEfiDxeSmmReadyToLockProtocolGuid callback
(SmmReadyToLockHandler(), "MdeModulePkg/Core/PiSmmCore/PiSmmCore.c").

Approached on a higher level, this driver provides the SmmIo member of the
EFI_SMM_SYSTEM_TABLE2 (SMST).

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

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index ca3be30..6cfd58e 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -292,6 +292,12 @@ [LibraryClasses.common.UEFI_APPLICATION]
 [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -697,4 +703,9 @@ [Components]
   # SMM_CORE
   #
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+
+  #
+  # Privileged drivers (DXE_SMM_DRIVER modules)
+  #
+  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 60f085a..6679e8a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -297,6 +297,12 @@ [LibraryClasses.common.UEFI_APPLICATION]
 [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -704,4 +710,9 @@ [Components.X64]
   # SMM_CORE
   #
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+
+  #
+  # Privileged drivers (DXE_SMM_DRIVER modules)
+  #
+  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 0621292..2651042 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -297,6 +297,12 @@ [LibraryClasses.common.UEFI_APPLICATION]
 [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+!ifdef $(DEBUG_ON_SERIAL_PORT)
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+!else
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+!endif
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -702,4 +708,9 @@ [Components]
   # SMM_CORE
   #
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+
+  #
+  # Privileged drivers (DXE_SMM_DRIVER modules)
+  #
+  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index f705918..e908198 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -360,6 +360,7 @@ [FV.DXEFV]
 INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+INF  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 !endif
 
 

@@ -495,3 +496,11 @@ [Rule.Common.SMM_CORE]
 UI   STRING="$(MODULE_NAME)" Optional
 VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
+
+[Rule.Common.DXE_SMM_DRIVER]
+  FILE SMM = $(NAMED_GUID) {
+SMM_DEPEXSMM_DEPEX Optional  $(INF_OUTPUT)/$(MODULE_NAME).depex
+PE32 PE32$(INF_OUTPUT)/$(MODULE_NAME).efi
+UI   STRING="$(MODULE_NAME)" Optional
+VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 93a8d44..5300a71 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -360,6 +360,7 @@ [FV.DXEFV]
 INF  OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+INF  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 !endif
 
 

@@ -495,3 +

[edk2] [PATCH v5 05/33] OvmfPkg: PlatformPei: allow caching in AddReservedMemoryBaseSizeHob()

2015-11-26 Thread Laszlo Ersek
AddReservedMemoryBaseSizeHob() should be able to set the same resource
attributes for reserved memory as AddMemoryBaseSizeHob() sets for system
memory. Add a new parameter called "Cacheable" to
AddReservedMemoryBaseSizeHob(), and set it to FALSE in the only caller we
have at the moment.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/PlatformPei/Platform.h | 3 ++-
 OvmfPkg/PlatformPei/Platform.c | 9 -
 OvmfPkg/PlatformPei/Xen.c  | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 8b6a976..dad3c61 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -50,7 +50,8 @@ AddUntestedMemoryBaseSizeHob (
 VOID
 AddReservedMemoryBaseSizeHob (
   EFI_PHYSICAL_ADDRESSMemoryBase,
-  UINT64  MemorySize
+  UINT64  MemorySize,
+  BOOLEAN Cacheable
   );
 
 VOID
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 1171d3a..8252dc9 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -88,7 +88,8 @@ AddIoMemoryBaseSizeHob (
 VOID
 AddReservedMemoryBaseSizeHob (
   EFI_PHYSICAL_ADDRESSMemoryBase,
-  UINT64  MemorySize
+  UINT64  MemorySize,
+  BOOLEAN Cacheable
   )
 {
   BuildResourceDescriptorHob (
@@ -96,6 +97,12 @@ AddReservedMemoryBaseSizeHob (
   EFI_RESOURCE_ATTRIBUTE_PRESENT |
   EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
   EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+  (Cacheable ?
+   EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+   EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+   EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE :
+   0
+   ) |
   EFI_RESOURCE_ATTRIBUTE_TESTED,
 MemoryBase,
 MemorySize
diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c
index 1886326..7fa9019 100644
--- a/OvmfPkg/PlatformPei/Xen.c
+++ b/OvmfPkg/PlatformPei/Xen.c
@@ -223,7 +223,7 @@ InitializeXen (
   // Reserve away HVMLOADER reserved memory [0xFC00,0xFD00).
   // This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.
   //
-  AddReservedMemoryBaseSizeHob (0xFC00, 0x100);
+  AddReservedMemoryBaseSizeHob (0xFC00, 0x100, FALSE);
 
   PcdSetBool (PcdPciDisableBusEnumeration, TRUE);
 
-- 
1.8.3.1


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


[edk2] [PATCH v5 24/33] OvmfPkg: SmmCpuFeaturesLib: customize state save map format

2015-11-26 Thread Laszlo Ersek
From: Paolo Bonzini 

This adjusts the previously introduced state save map access functions, to
account for QEMU and KVM's 64-bit state save map following the AMD spec
rather than the Intel one.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paolo Bonzini 
[ler...@redhat.com: reflow commit message, convert patch to CRLF]
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael Kinney 
---

Notes:
v3:
- new in v3

 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf |   1 +
 OvmfPkg/Include/Register/QemuSmramSaveStateMap.h| 184 

 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c   |  50 +++---
 3 files changed, 212 insertions(+), 23 deletions(-)

diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index 4b86deb..31edf3a 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -27,6 +27,7 @@ [Sources]
 
 [Packages]
   MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
   UefiCpuPkg/UefiCpuPkg.dec
 
 [LibraryClasses]
diff --git a/OvmfPkg/Include/Register/QemuSmramSaveStateMap.h 
b/OvmfPkg/Include/Register/QemuSmramSaveStateMap.h
new file mode 100644
index 000..389428d
--- /dev/null
+++ b/OvmfPkg/Include/Register/QemuSmramSaveStateMap.h
@@ -0,0 +1,184 @@
+/** @file
+SMRAM Save State Map Definitions.
+
+SMRAM Save State Map definitions based on contents of the 
+Intel(R) 64 and IA-32 Architectures Software Developer's Manual
+  Volume 3C, Section 34.4 SMRAM
+  Volume 3C, Section 34.5 SMI Handler Execution Environment
+  Volume 3C, Section 34.7 Managing Synchronous and Asynchronous SMIs
+
+and the AMD64 Architecture Programmer's Manual
+  Volume 2, Section 10.2 SMM Resources
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015, Red Hat, Inc.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD 
License
+which accompanies this distribution.  The full text of the license may be 
found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __QEMU_SMRAM_SAVE_STATE_MAP_H__
+#define __QEMU_SMRAM_SAVE_STATE_MAP_H__
+
+#pragma pack (1)
+
+///
+/// 32-bit SMRAM Save State Map
+///
+typedef struct {
+  UINT8   Reserved0[0x200]; // 7c00h
+  UINT8   Reserved1[0xf8];  // 7e00h
+  UINT32  SMBASE;   // 7ef8h
+  UINT32  SMMRevId; // 7efch
+  UINT16  IORestart;// 7f00h
+  UINT16  AutoHALTRestart;  // 7f02h
+  UINT8   Reserved2[0x9C];  // 7f08h
+  UINT32  IOMemAddr;// 7fa0h
+  UINT32  IOMisc;   // 7fa4h
+  UINT32  _ES;  // 7fa8h
+  UINT32  _CS;  // 7fach
+  UINT32  _SS;  // 7fb0h
+  UINT32  _DS;  // 7fb4h
+  UINT32  _FS;  // 7fb8h
+  UINT32  _GS;  // 7fbch
+  UINT32  Reserved3;// 7fc0h
+  UINT32  _TR;  // 7fc4h
+  UINT32  _DR7; // 7fc8h
+  UINT32  _DR6; // 7fcch
+  UINT32  _EAX; // 7fd0h
+  UINT32  _ECX; // 7fd4h
+  UINT32  _EDX; // 7fd8h
+  UINT32  _EBX; // 7fdch
+  UINT32  _ESP; // 7fe0h
+  UINT32  _EBP; // 7fe4h
+  UINT32  _ESI; // 7fe8h
+  UINT32  _EDI; // 7fech
+  UINT32  _EIP; // 7ff0h
+  UINT32  _EFLAGS;  // 7ff4h
+  UINT32  _CR3; // 7ff8h
+  UINT32  _CR0; // 7ffch
+} QEMU_SMRAM_SAVE_STATE_MAP32;
+
+///
+/// 64-bit SMRAM Save State Map
+///
+typedef struct {
+  UINT8   Reserved0[0x200];  // 7c00h
+
+  UINT16  _ES;   // 7e00h
+  UINT16  _ESAccessRights;   // 7e02h
+  UINT32  _ESLimit;  // 7e04h
+  UINT64  _ESBase;   // 7e08h
+
+  UINT16  _CS;   // 7e10h
+  UINT16  _CSAccessRights;   // 7e12h
+  UINT32  _CSLimit;  // 7e14h
+  UINT64  _CSBase;   // 7e18h
+
+  UINT16  _SS;   // 7e20h
+  UINT16  _SSAccessRights;   // 7e22h
+  UINT32  _SSLimit;  // 7e24h
+  UINT64  _SSBase;   // 7e28h
+
+  UINT16  _DS;   // 7e30h
+  UINT16  _DSAccessRights;   // 7e32h
+  UINT32  _DSLimit;  // 7e34h
+  UINT64  _DSBase;   // 7e38h
+
+  UINT16  _FS;   // 7e40h
+  UINT16  _FSAccessRights;   // 7e42h
+  UINT32  _FSLimit;  // 7e44h
+  UINT64  _FSBase;   // 7e48h
+
+  UINT16  _GS;   // 7e50h
+  UINT16  _GSAccessRights;   // 7e52h
+  UINT32  _GSLimit;  // 7e54h
+  UINT64  _GSBase;   // 7e58h
+
+  UINT32  _GDTRReserved1;// 7e60h
+  UINT16  _GDTRLimit;// 7e64h
+  UINT16  _GDTRReserved2;// 7e66h
+  UINT64  _GDTRBase; // 7e68h
+
+  UINT16  

[edk2] [PATCH v5 23/33] OvmfPkg: SmmCpuFeaturesLib: implement SMRAM state save map access

2015-11-26 Thread Laszlo Ersek
From: Paolo Bonzini 

This implementation copies SMRAM state save map access from the
PiSmmCpuDxeSmm module.

The most notable change is:

- dropping support for EFI_SMM_SAVE_STATE_REGISTER_IO

- changing the implementation of EFI_SMM_SAVE_STATE_REGISTER_LMA to use
  the SMM revision id instead of a local variable (which
  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c initializes from CPUID's LM
  bit).  This accounts for QEMU's implementation of x86_64, which always
  uses revision 0x20064 even if the LM bit is zero.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paolo Bonzini 
[ler...@redhat.com: reflow commit message & fix typo, convert patch to
 CRLF]
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael Kinney 
---

Notes:
v3:
- new in v3

 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf |   2 +
 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c   | 377 
+++-
 2 files changed, 376 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
index aa4792c..4b86deb 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -31,5 +31,7 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
+  BaseMemoryLib
   PcdLib
   DebugLib
+  SmmServicesTableLib
diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
index 3b6f186..b3d0e3a 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -15,11 +15,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+//
+// EFER register LMA bit
+//
+#define LMA BIT10
+
 /**
   The constructor function
 
@@ -128,7 +135,35 @@ SmmCpuFeaturesHookReturnFromSmm (
   IN UINT64NewInstructionPointer
   )
 {
-  return 0;
+  UINT64 OriginalInstructionPointer;
+  SMRAM_SAVE_STATE_MAP  *CpuSaveState = (SMRAM_SAVE_STATE_MAP *)CpuState;
+
+  if ((CpuSaveState->x86.SMMRevId & 0x) == 0) {
+OriginalInstructionPointer = (UINT64)CpuSaveState->x86._EIP;
+CpuSaveState->x86._EIP = (UINT32)NewInstructionPointer;
+//
+// Clear the auto HALT restart flag so the RSM instruction returns
+// program control to the instruction following the HLT instruction.
+//
+if ((CpuSaveState->x86.AutoHALTRestart & BIT0) != 0) {
+  CpuSaveState->x86.AutoHALTRestart &= ~BIT0;
+}
+  } else {
+OriginalInstructionPointer = CpuSaveState->x64._RIP;
+if ((CpuSaveState->x64.IA32_EFER & LMA) == 0) {
+  CpuSaveState->x64._RIP = (UINT32)NewInstructionPointer32;
+} else {
+  CpuSaveState->x64._RIP = (UINT32)NewInstructionPointer;
+}
+//
+// Clear the auto HALT restart flag so the RSM instruction returns
+// program control to the instruction following the HLT instruction.
+//
+if ((CpuSaveState->x64.AutoHALTRestart & BIT0) != 0) {
+  CpuSaveState->x64.AutoHALTRestart &= ~BIT0;
+}
+  }
+  return OriginalInstructionPointer;
 }
 
 /**
@@ -359,6 +394,213 @@ SmmCpuFeaturesSetSmmRegister (
   ASSERT (FALSE);
 }
 
+///
+/// Macro used to simplify the lookup table entries of type 
CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
+///
+#define SMM_CPU_OFFSET(Field) OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field)
+
+///
+/// Macro used to simplify the lookup table entries of type 
CPU_SMM_SAVE_STATE_REGISTER_RANGE
+///
+#define SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 }
+
+///
+/// Structure used to describe a range of registers
+///
+typedef struct {
+  EFI_SMM_SAVE_STATE_REGISTER  Start;
+  EFI_SMM_SAVE_STATE_REGISTER  End;
+  UINTNLength;
+} CPU_SMM_SAVE_STATE_REGISTER_RANGE;
+
+///
+/// Structure used to build a lookup table to retrieve the widths and offsets
+/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value
+///
+
+#define SMM_SAVE_STATE_REGISTER_FIRST_INDEX 1
+
+typedef struct {
+  UINT8   Width32;
+  UINT8   Width64;
+  UINT16  Offset32;
+  UINT16  Offset64Lo;
+  UINT16  Offset64Hi;
+  BOOLEAN Writeable;
+} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY;
+
+///
+/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER 
+/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
+///
+static CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] = {
+  SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_GDTBASE, 
EFI_SMM_SAVE_STATE_REGISTER_LDTINFO),
+  SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_ES,  
EFI_SMM_SAVE_STATE_REGISTER_RIP),
+  SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_RFLAGS,  
EFI_SMM_SAVE_STATE_REGISTER_CR4),
+  { (EFI_SMM_SAVE_STATE_REGISTER)0, (EF

[edk2] [PATCH v5 20/33] OvmfPkg: set gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection to FALSE

2015-11-26 Thread Laszlo Ersek
Explanation from Michael Kinney:

  This PCD allows a platform to provide PlatformSmmBspElection() in a
  platform specific SmmCpuPlatformHookLib instance to decide which CPU
  gets elected to be the BSP in each SMI.

  The SmmCpuPlatformHookLibNull [instance] always returns EFI_NOT_READY
  for that function, which makes the module behave the same as the PCD
  being set to FALSE.

  The default is TRUE, so the platform lib is always called, so a platform
  developer can implement the hook function and does not have to also
  change a PCD setting for the hook function to be active.

  A platform that wants to eliminate the call to the hook function
  [altogether] can set the PCD to FALSE.

  So for OVMF, I think it makes sense to set this PCD to FALSE in the DSC
  file.

Suggested-by: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v2:
- This patch replaces the v1 patch "OvmfPkg: import PCDs from
  Quark_EDKII_v1.1.0/IA32FamilyCpuBasePkg". That patch overrode the
  default for the PCD just the same, but it used different justification
  (= "Quark's IA32FamilyCpuBasePkg.dsc disables it too"). Plus, the goal
  of that patch was primarily to import PCDs to OvmfPkg.dec, under
  "gQuarkPortCpuTokenSpaceGuid", which is now unnecessary due to Mike's
  work.

 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 72132c7..dd9f7b5 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -345,6 +345,7 @@ [PcdsFeatureFlag]
 !endif
 !if $(SMM_REQUIRE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
 !endif
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 2a0d2d4..4d5943b 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -350,6 +350,7 @@ [PcdsFeatureFlag]
 !endif
 !if $(SMM_REQUIRE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
 !endif
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 2ac2b69..da041a6 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -350,6 +350,7 @@ [PcdsFeatureFlag]
 !endif
 !if $(SMM_REQUIRE) == TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE
 !endif
 
 [PcdsFixedAtBuild]
-- 
1.8.3.1


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


[edk2] [PATCH v5 21/33] OvmfPkg: import SmmCpuFeaturesLib from UefiCpuPkg

2015-11-26 Thread Laszlo Ersek
From: Paolo Bonzini 

The next patches will customize the implementation, but let's start from
the common version to better show the changes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paolo Bonzini 
[ler...@redhat.com: drop UNI file, keep whitespace intact, generate new
 FILE_GUID, split off DSC changes, reflow commit message, refresh against
 SVN r18958]
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---

Notes:
v5:
- refresh patch against SVN r18958 ("Add 2 APIs in SmmCpuFeaturesLib")
- drop Mike's R-b consequently

v3:
- new in v3

 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf |  39 ++
 OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c   | 658 

 2 files changed, 697 insertions(+)

diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
new file mode 100644
index 000..deb08bf
--- /dev/null
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
@@ -0,0 +1,39 @@
+## @file
+#  The CPU specific programming for PiSmmCpuDxeSmm module.
+#
+#  Copyright (c) 2009 - 2015, 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SmmCpuFeaturesLib
+  MODULE_UNI_FILE= SmmCpuFeaturesLib.uni
+  FILE_GUID  = AC9991BE-D77A-464C-A8DE-A873DB8A4836
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = SmmCpuFeaturesLib
+  CONSTRUCTOR= SmmCpuFeaturesLibConstructor
+
+[Sources]
+  SmmCpuFeaturesLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+  MemoryAllocationLib
+  DebugLib
+
+[Pcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber## 
SOMETIMES_CONSUMES
diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
new file mode 100644
index 000..3e480e1
--- /dev/null
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -0,0 +1,658 @@
+/** @file
+The CPU specific programming for PiSmmCpuDxeSmm module.
+
+Copyright (c) 2010 - 2015, 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.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+//
+// Machine Specific Registers (MSRs)
+//
+#define  SMM_FEATURES_LIB_IA32_MTRR_CAP0x0FE
+#define  SMM_FEATURES_LIB_IA32_FEATURE_CONTROL 0x03A
+#define  SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE   0x1F2
+#define  SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK   0x1F3
+#define  SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE  0x0A0
+#define  SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK  0x0A1
+#defineEFI_MSR_SMRR_MASK   0xF000
+#defineEFI_MSR_SMRR_PHYS_MASK_VALIDBIT11
+#define  SMM_FEATURES_LIB_SMM_FEATURE_CONTROL  0x4E0
+
+//
+// MSRs required for configuration of SMM Code Access Check
+//
+#define SMM_FEATURES_LIB_IA32_MCA_CAP  0x17D
+#define   SMM_CODE_ACCESS_CHK_BIT  BIT58
+
+//
+// Set default value to assume SMRR is not supported
+//
+BOOLEAN  mSmrrSupported = FALSE;
+
+//
+// Set default value to assume MSR_SMM_FEATURE_CONTROL is not supported
+//
+BOOLEAN  mSmmFeatureControlSupported = FALSE;
+
+//
+// Set default value to assume IA-32 Architectural MSRs are used
+//
+UINT32  mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE;
+UINT32  mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK;
+
+//
+// Set default value to assume MTRRs need to be configured on each SMI
+//
+BOOLEAN  mNeedConfigureMtrrs = TRUE;
+
+//
+// Array for state of SMRR enable on all CPUs
+//
+BOOLEAN  *mSmrrEnabled;
+
+/**
+  The constructor function
+
+  @param[in]  ImageHandle  The firmware allocated handle for the EFI image.
+  @param[in]  SystemTable  A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS  The constructor always returns EFI_SUCCESS.
+
+**/
+E

[edk2] [PATCH v5 16/33] OvmfPkg: resolve ReportStatusCodeLib for DXE_SMM_DRIVER modules

2015-11-26 Thread Laszlo Ersek
PiSmmCpuDxeSmm depends on this library class, and it's okay to resolve it
generally for all DXE_SMM_DRIVER modules.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index a19d4e2..6a93fd2 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -299,6 +299,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
   
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index d177154..dbaf8fb 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -304,6 +304,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
   
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 7908a31..a7efe52 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -304,6 +304,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
   
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
-- 
1.8.3.1


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


[edk2] [PATCH v5 28/33] OvmfPkg: build PiSmmCpuDxeSmm for -D SMM_REQUIRE

2015-11-26 Thread Laszlo Ersek
At this point we can enable building PiSmmCpuDxeSmm.

CPU specific features, like SMRR detection, and functions that are used to
initialize SMM and process SMIs, are abstracted through the
SmmCpuFeaturesLib class for the PiSmmCpuDxeSmm module. Resolve it to our
own implementation under OvmfPkg -- it allows PiSmmCpuDxeSmm to work with
QEMU's and KVM's 64-bit state save map format, which follows the
definition from AMD's programmer manual.

SmmCpuPlatformHookLib provides platform specific functions that are used
to initialize SMM and process SMIs. Resolve it to the one Null instance
provided by UefiCpuPkg, which is expected to work for most platforms.

Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
[pbonz...@redhat.com: resolve the SmmCpuFeaturesLib class to OVMF's own
 instance]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael Kinney 
---

Notes:
v5:
- remove paragraph from commit message stating "PiSmmCpuDxeSmm is not
  yet intended to function correctly with regard to S3"; the previous
  patch now builds UefiCpuPkg/CpuS3DataDxe

v4:
- Drop the SmmLib resolution from the DSC files, and the matching
  paragraph from the commit message. Starting with SVN r18673 / git
  f40577c3563f ("UefiCpuPkg: PiSmmCpuDxeSmm: Remove unused references to
  SmmLib"), PiSmmCpuDxeSmm depends on SmmLib no more.

v3:
- resolve SmmCpuFeaturesLib to OvmfPkg's own instance [Paolo]

v2:
- The module builds now for X64 too, thanks to Intel for open sourcing
  the X64 SMM entry vector (huge kudos). Update the commit message
  accordingly.
- Thanks to Mike, PiSmmCpuDxeSmm and SmmCpuPlatformHookLibNull are now
  under UefiCpuPkg; update pathnames in the DSC / FDF files accordingly.
- Version 2 of this patch also obviates "OvmfPkg: PiSmmCpuDxeSmm:
  eliminate SmmLib dependency" from v1.
- Resolve SmmCpuFeaturesLib. This abstraction is new in Mike's
  PiSmmCpuDxeSmm module; Quark used to have similar code in
  "SmmFeatures.c" non-separably.

 OvmfPkg/OvmfPkgIa32.dsc| 5 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 5 +
 OvmfPkg/OvmfPkgX64.dsc | 5 +
 OvmfPkg/OvmfPkgIa32.fdf| 1 +
 OvmfPkg/OvmfPkgIa32X64.fdf | 1 +
 OvmfPkg/OvmfPkgX64.fdf | 1 +
 6 files changed, 18 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 5a63e5b..a8a1107 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -736,4 +736,9 @@ [Components]
 
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
   }
+  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
+
+  
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
+  SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  }
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index b99a1c0..d873043 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -743,4 +743,9 @@ [Components.X64]
 
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
   }
+  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
+
+  
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
+  SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  }
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index cd52bda..9f3168f 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -741,4 +741,9 @@ [Components]
 
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
   }
+  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
+
+  
SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
+  SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  }
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 83702a1..4337ea8 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -363,6 +363,7 @@ [FV.DXEFV]
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 INF  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+INF  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
 !endif
 
 

diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 1af0c17..ea2936a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -363,6 +363,7 @@ [FV.DXEFV]
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
 INF  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+INF  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
 !endif
 
 

diff --git a/OvmfPkg/OvmfPk

[edk2] [PATCH v5 13/33] OvmfPkg: LockBoxLib: -D SMM_REQUIRE excludes our fake lockbox

2015-11-26 Thread Laszlo Ersek
When the user builds OVMF with -D SMM_REQUIRE, our LockBox implementation
must not be used, since it doesn't actually protect data in the LockBox
from the runtime guest OS. Add an according assert to
LockBoxLibInitialize().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Paolo Bonzini 
Reviewed-by: Jordan Justen 
---

Notes:
v5:
- split out LockBoxLib changes from "OvmfPkg: LockBox: -D SMM_REQUIRE
  excludes our fake lockbox" [Jordan]

 OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf | 3 +++
 OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf  | 3 +++
 OvmfPkg/Library/LockBoxLib/LockBoxLib.c   | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf 
b/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
index 7203d07..81c893e 100644
--- a/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
+++ b/OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
@@ -42,3 +42,6 @@ [LibraryClasses]
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
+
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf 
b/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
index a4d27a5..08973a4 100644
--- a/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
+++ b/OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
@@ -43,3 +43,6 @@ [LibraryClasses]
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
+
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
diff --git a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c 
b/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
index 89050ac..45481b9 100644
--- a/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
+++ b/OvmfPkg/Library/LockBoxLib/LockBoxLib.c
@@ -44,6 +44,8 @@ LockBoxLibInitialize (
 {
   UINTN NumEntries;
 
+  ASSERT (!FeaturePcdGet (PcdSmmSmramRequire));
+
   if (PcdGet32 (PcdOvmfLockBoxStorageSize) < sizeof (LOCK_BOX_GLOBAL)) {
 return RETURN_UNSUPPORTED;
   }
-- 
1.8.3.1


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


[edk2] [PATCH v5 08/33] OvmfPkg: add DXE_DRIVER for providing TSEG-as-SMRAM during boot-time DXE

2015-11-26 Thread Laszlo Ersek
The SMM core depends on EFI_SMM_ACCESS2_PROTOCOL. This small driver (which
is a thin wrapper around "OvmfPkg/SmmAccess/SmramInternal.c" that was
added in the previous patch) provides that protocol.

Notably, EFI_SMM_ACCESS2_PROTOCOL is for boot time only, therefore
our MODULE_TYPE is not DXE_RUNTIME_DRIVER.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael Kinney 
---

Notes:
v5:
- list "SmramInternal.h" in "SmmAccess2Dxe.inf" as a source file [Mike]
- fix up "PRODUCES" comment for "gEfiSmmAccess2ProtocolGuid" in
  "SmmAccess2Dxe.inf" [Mike]

 OvmfPkg/OvmfPkgIa32.dsc |   4 +
 OvmfPkg/OvmfPkgIa32X64.dsc  |   4 +
 OvmfPkg/OvmfPkgX64.dsc  |   4 +
 OvmfPkg/OvmfPkgIa32.fdf |   4 +
 OvmfPkg/OvmfPkgIa32X64.fdf  |   4 +
 OvmfPkg/OvmfPkgX64.fdf  |   4 +
 OvmfPkg/SmmAccess/SmmAccess2Dxe.inf |  58 
 OvmfPkg/SmmAccess/SmmAccess2Dxe.c   | 156 
 8 files changed, 238 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 0b729ca..d7bc38d 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -672,3 +672,7 @@ [Components]
 !endif
 
   OvmfPkg/PlatformDxe/Platform.inf
+
+!if $(SMM_REQUIRE) == TRUE
+  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+!endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 7f672d9..e17cbe5 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -679,3 +679,7 @@ [Components.X64]
 !endif
 
   OvmfPkg/PlatformDxe/Platform.inf
+
+!if $(SMM_REQUIRE) == TRUE
+  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+!endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 986c019..a748fb3 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -677,3 +677,7 @@ [Components]
 !endif
 
   OvmfPkg/PlatformDxe/Platform.inf
+
+!if $(SMM_REQUIRE) == TRUE
+  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+!endif
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 650dab1..285720f 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -355,6 +355,10 @@ [FV.DXEFV]
 INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
 INF  OvmfPkg/PlatformDxe/Platform.inf
 
+!if $(SMM_REQUIRE) == TRUE
+INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+!endif
+
 

 
 [FV.FVMAIN_COMPACT]
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 5830401..02e8752 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -355,6 +355,10 @@ [FV.DXEFV]
 INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
 INF  OvmfPkg/PlatformDxe/Platform.inf
 
+!if $(SMM_REQUIRE) == TRUE
+INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+!endif
+
 

 
 [FV.FVMAIN_COMPACT]
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 9dd6171..f04c36b 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -355,6 +355,10 @@ [FV.DXEFV]
 INF  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
 INF  OvmfPkg/PlatformDxe/Platform.inf
 
+!if $(SMM_REQUIRE) == TRUE
+INF  OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
+!endif
+
 

 
 [FV.FVMAIN_COMPACT]
diff --git a/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf 
b/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
new file mode 100644
index 000..31e4dfa
--- /dev/null
+++ b/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf
@@ -0,0 +1,58 @@
+## @file
+# A DXE_DRIVER providing SMRAM access by producing EFI_SMM_ACCESS2_PROTOCOL.
+#
+# Q35 TSEG is expected to have been verified and set up by the SmmAccessPei
+# driver.
+#
+# Copyright (C) 2013, 2015, Red Hat, Inc.
+#
+# 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.
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SmmAccess2Dxe
+  FILE_GUID  = AC95AD3D-4366-44BF-9A62-E4B29D7A2206
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  PI_SPECIFICATION_VERSION   = 0x00010400
+  ENTRY_POINT= SmmAccess2DxeEntryPoint
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  SmmAccess2Dxe.c
+  SmramInternal.c
+  SmramInternal.h
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  PcdLib
+  PciLib
+  UefiBootServicesTableLib
+  UefiDrive

[edk2] [PATCH v5 07/33] OvmfPkg: add PEIM for providing TSEG-as-SMRAM during PEI

2015-11-26 Thread Laszlo Ersek
"MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf" is the
LockBoxLib instance with SMRAM access for the PEI phase.

Said library instance must, and can, access the LockBox data in SMRAM
directly if it is invoked before SMBASE relocation / SMI handler
installation. In that case, it only needs PEI_SMM_ACCESS_PPI from the
platform, and it doesn't depend on EFI_PEI_SMM_COMMUNICATION_PPI.

OVMF satisfies the description in SVN r18823 ("MdeModulePkg:
SmmLockBoxPeiLib: work without EFI_PEI_SMM_COMMUNICATION_PPI"): in OVMF,
only S3Resume2Pei links against SmmLockBoxPeiLib.

Therefore, introduce a PEIM that produces the PEI_SMM_ACCESS_PPI
interface, enabling SmmLockBoxPeiLib to work; we can omit including
"UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf".

The load / installation order of S3Resume2Pei and SmmAccessPei is
indifferent. SmmAccessPei produces the gEfiAcpiVariableGuid HOB during its
installation (which happens during PEI), but S3Resume2Pei accesses the HOB
only when the DXE IPL calls its S3RestoreConfig2 PPI member, as last act
of PEI.

MCH_SMRAM_D_LCK and MCH_ESMRAMC_T_EN are masked out the way they are, in
SmmAccessPeiEntryPoint() and SmramAccessOpen() respectively, in order to
prevent VS20xx from warning about the (otherwise fully intentional)
truncation in the UINT8 casts. (Warnings reported by Michael Kinney.)

Cc: Michael Kinney 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Michael Kinney 
---

Notes:
v5:
- drop null implementation of EFI_PEI_SMM_COMMUNICATION_PPI [Mike,
  Jordan, Jiewen]
- list "SmramInternal.h" in "SmmAccessPei.inf" as a source file [Mike]
- fix up "PRODUCES" comment for "gPeiSmmAccessPpiGuid" in
  "SmmAccessPei.inf" [Mike]
- replace _ASSERT (FALSE) with ASSERT (FALSE) + CpuDeadLoop () [Mike]

v3:
- update bit-neg expressions to silence VS20xx warnings [Mike]

 OvmfPkg/OvmfPkgIa32.dsc|   6 +
 OvmfPkg/OvmfPkgIa32X64.dsc |   6 +
 OvmfPkg/OvmfPkgX64.dsc |   6 +
 OvmfPkg/OvmfPkgIa32.fdf|   3 +
 OvmfPkg/OvmfPkgIa32X64.fdf |   3 +
 OvmfPkg/OvmfPkgX64.fdf |   3 +
 OvmfPkg/SmmAccess/SmmAccessPei.inf |  69 
 OvmfPkg/SmmAccess/SmramInternal.h  |  89 +
 OvmfPkg/SmmAccess/SmmAccessPei.c   | 393 
 OvmfPkg/SmmAccess/SmramInternal.c  | 188 ++
 10 files changed, 766 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index c6850ff..0b729ca 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -445,6 +445,12 @@ [Components]
 
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
   }
+!if $(SMM_REQUIRE) == TRUE
+  OvmfPkg/SmmAccess/SmmAccessPei.inf {
+
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  }
+!endif
 
   #
   # DXE Phase modules
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index dd65bf9..7f672d9 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -451,6 +451,12 @@ [Components.IA32]
 
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
   }
+!if $(SMM_REQUIRE) == TRUE
+  OvmfPkg/SmmAccess/SmmAccessPei.inf {
+
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  }
+!endif
 
 [Components.X64]
   #
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 0de3c85..986c019 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -450,6 +450,12 @@ [Components]
 
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
   }
+!if $(SMM_REQUIRE) == TRUE
+  OvmfPkg/SmmAccess/SmmAccessPei.inf {
+
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  }
+!endif
 
   #
   # DXE Phase modules
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 44e4a92..650dab1 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -171,6 +171,9 @@ [FV.PEIFV]
 INF  OvmfPkg/PlatformPei/PlatformPei.inf
 INF  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 INF  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+!if $(SMM_REQUIRE) == TRUE
+INF  OvmfPkg/SmmAccess/SmmAccessPei.inf
+!endif
 
 

 
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 67bfbe7..5830401 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -171,6 +171,9 @@ [FV.PEIFV]
 INF  OvmfPkg/PlatformPei/PlatformPei.inf
 INF  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
 INF  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+!if $(SMM_REQUIRE) == TRUE
+INF  OvmfPkg/SmmAccess/SmmAccessPei.inf
+!endif
 
 

 
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 6624789..9dd6171 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -171,6 +171,9 @@ [FV.PEIFV]
 INF  OvmfPkg/PlatformPei/PlatformPei.inf
 INF  MdeModulePkg/Core/DxeIplPeim/DxeI

[edk2] [PATCH v5 14/33] OvmfPkg: PlatformPei: don't allocate fake lockbox if SMM_REQUIRE

2015-11-26 Thread Laszlo Ersek
Since our fake LockBox must not be selected with -D SMM_REQUIRE (see the
previous patch), it makes sense to set aside memory for it only if -D
SMM_REQUIRE is absent. Modify InitializeRamRegions() accordingly.

This patch completes the -D SMM_REQUIRE-related tweaking of the special
OVMF memory areas.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Paolo Bonzini 
Reviewed-by: Jordan Justen 
---

Notes:
v5:
- split out PlatformPei changes from "OvmfPkg: LockBox: -D SMM_REQUIRE
  excludes our fake lockbox" [Jordan]

 OvmfPkg/PlatformPei/MemDetect.c | 40 ++--
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 1bdc2df..455fcbb 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -407,25 +407,27 @@ InitializeRamRegions (
   }
 
   if (mBootMode != BOOT_ON_S3_RESUME) {
-//
-// Reserve the lock box storage area
-//
-// Since this memory range will be used on S3 resume, it must be
-// reserved as ACPI NVS.
-//
-// If S3 is unsupported, then various drivers might still write to the
-// LockBox area. We ought to prevent DXE from serving allocation requests
-// such that they would overlap the LockBox storage.
-//
-ZeroMem (
-  (VOID*)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
-  (UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize)
-  );
-BuildMemoryAllocationHob (
-  (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
-  (UINT64)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize),
-  mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
-  );
+if (!FeaturePcdGet (PcdSmmSmramRequire)) {
+  //
+  // Reserve the lock box storage area
+  //
+  // Since this memory range will be used on S3 resume, it must be
+  // reserved as ACPI NVS.
+  //
+  // If S3 is unsupported, then various drivers might still write to the
+  // LockBox area. We ought to prevent DXE from serving allocation requests
+  // such that they would overlap the LockBox storage.
+  //
+  ZeroMem (
+(VOID*)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
+(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize)
+);
+  BuildMemoryAllocationHob (
+(EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
+(UINT64)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize),
+mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
+);
+}
 
 if (FeaturePcdGet (PcdSmmSmramRequire)) {
   UINT32 TsegSize;
-- 
1.8.3.1


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


[edk2] [PATCH v5 15/33] OvmfPkg: LockBox: use SMM stack with -D SMM_REQUIRE

2015-11-26 Thread Laszlo Ersek
During DXE, drivers save data in the LockBox. A save operation is layered
as follows:

- The unprivileged driver wishing to store data in the LockBox links
  against the "MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf"
  library instance.

  The library allows the unprivileged driver to format requests for the
  privileged SMM LockBox driver (see below), and to parse responses.

  We apply this resolution for DXE_DRIVER modules.

- The privileged SMM LockBox driver is built from
  "MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf". This driver
  has module type DXE_SMM_DRIVER and can access SMRAM.

  The driver delegates command parsing and response formatting to
  "MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf".

  Therefore we include this DXE_SMM_DRIVER in the build, and apply said
  resolution specifically to it.

  (Including the driver requires us to resolve a few of other library
  classes for DXE_SMM_DRIVER modules.)

- In PEI, the S3 Resume PEIM (UefiCpuPkg/Universal/Acpi/S3Resume2Pei)
  retrieves data from the LockBox. It is capable of searching SMRAM
  itself.

  We resolve LockBoxLib to
  "MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf" specifically
  for this one PEIM.

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

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 6cfd58e..a19d4e2 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -106,7 +106,9 @@ [LibraryClasses]
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
   VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
+!endif
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
 
 !ifdef $(SOURCE_DEBUG_ENABLE)
@@ -272,7 +274,11 @@ [LibraryClasses.common.DXE_DRIVER]
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
   PlatformBdsLib|OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+!if $(SMM_REQUIRE) == TRUE
+  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
+!else
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
+!endif
 !ifdef $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
@@ -292,6 +298,9 @@ [LibraryClasses.common.UEFI_APPLICATION]
 [LibraryClasses.common.DXE_SMM_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+  
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
   
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -461,6 +470,9 @@ [Components]
   UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf {
 
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+!if $(SMM_REQUIRE) == TRUE
+  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf
+!endif
   }
 !if $(SMM_REQUIRE) == TRUE
   OvmfPkg/SmmAccess/SmmAccessPei.inf {
@@ -708,4 +720,8 @@ [Components]
   # Privileged drivers (DXE_SMM_DRIVER modules)
   #
   UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
+  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf {
+
+  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
+  }
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 6679e8a..d177154 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -111,7 +111,9 @@ [LibraryClasses]
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf
   VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
+!endif
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
 
 !ifdef $(SOURCE_DEBUG_ENABLE)
@@ -277,7 +279,11 @@ [LibraryClasses.common.DXE_DRIVER]
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
   PlatformBdsLib|OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+!if $(SMM_REQUIRE) == TRUE
+  LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf
+!else
   Lo

[edk2] [PATCH v5 04/33] OvmfPkg: decompress FVs on S3 resume if SMM_REQUIRE is set

2015-11-26 Thread Laszlo Ersek
If OVMF was built with -D SMM_REQUIRE, that implies that the runtime OS is
not trusted and we should defend against it tampering with the firmware's
data.

One such datum is the PEI firmware volume (PEIFV). Normally PEIFV is
decompressed on the first boot by SEC, then the OS preserves it across S3
suspend-resume cycles; at S3 resume SEC just reuses the originally
decompressed PEIFV.

However, if we don't trust the OS, then SEC must decompress PEIFV from the
pristine flash every time, lest we execute OS-injected code or work with
OS-injected data.

Due to how FVMAIN_COMPACT is organized, we can't decompress just PEIFV;
the decompression brings DXEFV with itself, plus it uses a temporary
output buffer and a scratch buffer too, which even reach above the end of
the finally installed DXEFV. For this reason we must keep away a
non-malicious OS from DXEFV too, plus the memory up to
PcdOvmfDecomprScratchEnd.

The delay introduced by the LZMA decompression on S3 resume is negligible.

If -D SMM_REQUIRE is not specified, then PcdSmmSmramRequire remains FALSE
(from the DEC file), and then this patch has no effect (not counting some
changed debug messages).

If QEMU doesn't support S3 (or the user disabled it on the QEMU command
line), then this patch has no effect also.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
Reviewed-by: Jordan Justen 
---

Notes:
v2:
- PcdOvmfDecomprScratchEnd => PcdOvmfDecompressionScratchEnd [Jordan]
  

- "S3 resume (insecure)" => "S3 resume",
  "S3 resume (hopefully secure)" => "S3 resume (with PEI decompression)"
  [Jordan]
  

 OvmfPkg/PlatformPei/PlatformPei.inf |  4 +++
 OvmfPkg/Sec/SecMain.inf |  3 +++
 OvmfPkg/PlatformPei/Fv.c| 27 +++-
 OvmfPkg/PlatformPei/MemDetect.c | 11 +++-
 OvmfPkg/Sec/SecMain.c   | 16 ++--
 5 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf 
b/OvmfPkg/PlatformPei/PlatformPei.inf
index 0c7ae5f..62f64fe 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -74,6 +74,7 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
   gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
   gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
@@ -88,6 +89,9 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
 
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
+
 [Ppis]
   gEfiPeiMasterBootModePpiGuid
 
diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 9e8571d..711b595 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -71,3 +71,6 @@ [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
   gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
+
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
diff --git a/OvmfPkg/PlatformPei/Fv.c b/OvmfPkg/PlatformPei/Fv.c
index 3ed775c..248c585 100644
--- a/OvmfPkg/PlatformPei/Fv.c
+++ b/OvmfPkg/PlatformPei/Fv.c
@@ -32,6 +32,8 @@ PeiFvInitialization (
   VOID
   )
 {
+  BOOLEAN SecureS3Needed;
+
   DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
 
   //
@@ -50,16 +52,39 @@ PeiFvInitialization (
   //
   BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
 
+  SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);
+
   //
   // Create a memory allocation HOB for the DXE FV.
   //
+  // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
+  // firmware volumes at S3 resume too, hence we need to keep away the OS from
+  // DXEFV as well. Otherwise we only need to keep away DXE itself from the
+  // DXEFV area.
+  //
   BuildMemoryAllocationHob (
 PcdGet32 (PcdOvmfDxeMemFvBase),
 PcdGet32 (PcdOvmfDxeMemFvSize),
-EfiBootServicesData
+SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
 );
 
   //
+  // Additionally, said decompression will use temporary memory above the end
+  // of DXEFV, so let's keep away the OS from there too.
+  //
+  if (SecureS3Needed) {
+UINT32 DxeMemFvEnd;
+
+DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
+  PcdGet32 (PcdOvmfDxeMemFvSize);
+BuildMemoryAllocationHob (
+  DxeMemFvEnd,
+  PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,
+  EfiACPIMemoryNVS
+  );
+  }
+
+  //
   // Let PEI know about the DXE FV so it can find 

[edk2] [PATCH v5 00/33] OvmfPkg: support SMM for better security

2015-11-26 Thread Laszlo Ersek
Public branch: .

The big change in this version is that Mike has flattened, cleaned up,
and incorporated CpuS3DataDxe from OvmfPkg/QuarkPort to UefiCpuPkg.
(Huge kudos for that again!) The OvmfPkg/QuarkPort directory is
therefore gone, as are any other mentions of Quark in the source code
and in the commit messages.

Another important change is that the series no longer introduces a
separate null implementation of EFI_PEI_SMM_COMMUNICATION_PPI under
OvmfPkg -- kudos to Jiewen for suggesting and accepting a PEI LockBoxLib
patch that has made this possible.

In addition, the series addresses all agreed-upon v4 feedback, and picks
up all review tags too (some of which were given dependent on addressing
said review feedback).

In total, the following patches have seen modifications -- please see
their Notes sections individually for the changes:

  [PATCH v5 02/33] OvmfPkg: Sec: force reinit of BaseExtractGuidedSectionLib 
handler table
  [PATCH v5 07/33] OvmfPkg: add PEIM for providing TSEG-as-SMRAM during PEI
  [PATCH v5 08/33] OvmfPkg: add DXE_DRIVER for providing TSEG-as-SMRAM during 
boot-time DXE
  [PATCH v5 09/33] OvmfPkg: implement EFI_SMM_CONTROL2_PROTOCOL with a 
DXE_RUNTIME_DRIVER
  [PATCH v5 10/33] OvmfPkg: pull in the SMM IPL and SMM core
  [PATCH v5 13/33] OvmfPkg: LockBoxLib: -D SMM_REQUIRE excludes our fake lockbox
  [PATCH v5 14/33] OvmfPkg: PlatformPei: don't allocate fake lockbox if 
SMM_REQUIRE
  [PATCH v5 19/33] OvmfPkg: select LocalApicLib instance with x2apic support
  [PATCH v5 21/33] OvmfPkg: import SmmCpuFeaturesLib from UefiCpuPkg
  [PATCH v5 22/33] OvmfPkg: SmmCpuFeaturesLib: remove unnecessary bits
  [PATCH v5 27/33] OvmfPkg: build CpuS3DataDxe for -D SMM_REQUIRE
  [PATCH v5 28/33] OvmfPkg: build PiSmmCpuDxeSmm for -D SMM_REQUIRE
  [PATCH v5 33/33] OvmfPkg: README: document SMM status

In the process I had to drop two R-b tags from Mike, because I had to
refresh Paolo's patches (marked #21 and #22 above) against the meanwhile
extended "UefiCpuPkg/Library/SmmCpuFeaturesLib" instance. Although the
end result in the "OvmfPkg/Library/SmmCpuFeaturesLib" instance is
exactly the same as before -- modulo the whitespace and comment
cleanups, and the two new empty APIs now inherited from UefiCpuPkg --, I
felt the review process would be cleaner and more integral if Mike took
a look again. Much appreciated.

Accounting for all of the above, only the following patches need
reviews:

  [PATCH v5 21/33] OvmfPkg: import SmmCpuFeaturesLib from UefiCpuPkg
  [PATCH v5 22/33] OvmfPkg: SmmCpuFeaturesLib: remove unnecessary bits
  [PATCH v5 27/33] OvmfPkg: build CpuS3DataDxe for -D SMM_REQUIRE

After which I plan to commit the series.

Cc: Paolo Bonzini 
Cc: Jordan Justen 
Cc: Michael Kinney 
Cc: Jiewen Yao 

Thanks
Laszlo

Laszlo Ersek (27):
  OvmfPkg: introduce -D SMM_REQUIRE and PcdSmmSmramRequire
  OvmfPkg: Sec: force reinit of BaseExtractGuidedSectionLib handler
table
  OvmfPkg: Sec: assert the build-time calculated end of the scratch
buffer
  OvmfPkg: decompress FVs on S3 resume if SMM_REQUIRE is set
  OvmfPkg: PlatformPei: allow caching in AddReservedMemoryBaseSizeHob()
  OvmfPkg: PlatformPei: account for TSEG size with PcdSmmSmramRequire
set
  OvmfPkg: add PEIM for providing TSEG-as-SMRAM during PEI
  OvmfPkg: add DXE_DRIVER for providing TSEG-as-SMRAM during boot-time
DXE
  OvmfPkg: implement EFI_SMM_CONTROL2_PROTOCOL with a DXE_RUNTIME_DRIVER
  OvmfPkg: pull in the SMM IPL and SMM core
  OvmfPkg: pull in CpuIo2Smm driver
  OvmfPkg: AcpiS3SaveDxe: don't fake LockBox protocol if SMM_REQUIRE
  OvmfPkg: LockBoxLib: -D SMM_REQUIRE excludes our fake lockbox
  OvmfPkg: PlatformPei: don't allocate fake lockbox if SMM_REQUIRE
  OvmfPkg: LockBox: use SMM stack with -D SMM_REQUIRE
  OvmfPkg: resolve ReportStatusCodeLib for DXE_SMM_DRIVER modules
  OvmfPkg: resolve CpuExceptionHandlerLib for DXE_SMM_DRIVER modules
  OvmfPkg: select LocalApicLib instance with x2apic support
  OvmfPkg: set gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection to
FALSE
  OvmfPkg: any AP in SMM should not wait for the BSP for more than 100
ms
  OvmfPkg: build CpuS3DataDxe for -D SMM_REQUIRE
  OvmfPkg: build PiSmmCpuDxeSmm for -D SMM_REQUIRE
  OvmfPkg: QemuFlashFvbServicesRuntimeDxe: add DXE_SMM_DRIVER build
  OvmfPkg: QemuFlashFvbServicesRuntimeDxe: adhere to -D SMM_REQUIRE
  OvmfPkg: consolidate variable driver stack in DSC and FDF files
  OvmfPkg: pull in SMM-based variable driver stack
  OvmfPkg: README: document SMM status

Michael Kinney (1):
  OvmfPkg: resolve DebugAgentLib for DXE_SMM_DRIVER modules

Paolo Bonzini (5):
  OvmfPkg: import SmmCpuFeaturesLib from UefiCpuPkg
  OvmfPkg: SmmCpuFeaturesLib: remove unnecessary bits
  OvmfPkg: SmmCpuFeaturesLib: implement SMRAM state save map access
  OvmfPkg: SmmCpuFeaturesLib: customize state save map format
  OvmfPkg: use relaxed AP SMM synchronization mode

 OvmfPkg/OvmfPkg.dec  

[edk2] [PATCH v5 02/33] OvmfPkg: Sec: force reinit of BaseExtractGuidedSectionLib handler table

2015-11-26 Thread Laszlo Ersek
BaseExtractGuidedSectionLib uses a table at the static physical address
PcdGuidedExtractHandlerTableAddress, and modules that are linked against
BaseExtractGuidedSectionLib are expected to work together on that table.
Namely, some modules can register handlers for GUIDed sections, some other
modules can decode such sections with the pre-registered handlers. The
table carries persistent information between these modules.

BaseExtractGuidedSectionLib checks a table signature whenever it is used
(by whichever module that is linked against it), and at the first use
(identified by a signature mismatch) it initializes the table.

One of the module types that BaseExtractGuidedSectionLib can be used with
is SEC, if the SEC module in question runs with the platform's RAM already
available.

In such cases the question emerges whether the initial contents of the RAM
(ie. contents that predate the very first signature check) can be trusted.
Normally RAM starts out with all zeroes (leading to a signature mismatch
on the first check); however a malicious runtime OS can populate the area
with some payload, then force a warm platform reset or an S3
suspend-and-resume. In such cases the signature check in the SEC module
might not fire, and ExtractGuidedSectionDecode() might run code injected
by the runtime OS, as part of SEC (ie. with high privileges).

Therefore we clear the handler table in SEC.

See also git commit ad43bc6b2e (SVN rev 15433) -- this patch secures the
(d) and (e) code paths examined in that commit. Furthermore, a
non-malicious runtime OS will observe no change in behavior; see case (c)
in said commit.

Cc: Michael Kinney 
Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
[michael.d.kin...@intel.com: prevent VS20xx loop intrinsic with volatile]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney 
Reviewed-by: Michael Kinney 
Reviewed-by: Jordan Justen 
---

Notes:
v5:
- condense comment before clearing BaseExtractGuidedSectionLib handler
  table [Jordan]
- clear table regardless of PcdSmmSmramRequire; update commit message
  accordingly [Mike, Jordan]
- drop EFI_D_VERBOSE message about clearing the table (which is now
  unconditional) [Jordan]
- delay addition of PcdSmmSmramRequire to SecMain.inf until "OvmfPkg:
  decompress FVs on S3 resume if SMM_REQUIRE is set"; that patch is the
  one that requires the PCD first now [Laszlo]
- pick up Jordan's R-b

v3:
- volatile-qualify the Table pointer to prevent VS20xx from turning the
  zeroing loop into a compiler intrinsic [Mike]

v2:
- This implements option #2 from Jordan's feedback at
  .
  Liming was okay with that option:
  .

- This patch replaces the following patches from the v1 series:

  [PATCH 03/58] MdePkg: BaseExtractGuidedSectionLib: allow forced reinit
of handler table
  

  [PATCH 04/58] OvmfPkg: set PcdBaseExtractGuidedSectionLibForceInit for
SEC on SMM_REQUIRE
  

 OvmfPkg/Sec/SecMain.inf |  2 ++
 OvmfPkg/Sec/SecMain.c   | 13 +
 2 files changed, 15 insertions(+)

diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 2f78f3c..415731c 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -68,3 +68,5 @@ [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
+  gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
+  gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 4f87059..0cf127a 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -698,6 +698,19 @@ SecCoreStartupWithStack (
   SEC_IDT_TABLE   IdtTableInStack;
   IA32_DESCRIPTOR IdtDescriptor;
   UINT32  Index;
+  volatile UINT8  *Table;
+
+  //
+  // To ensure SMM can't be compromised on S3 resume, we must force re-init of
+  // the BaseExtractGuidedSectionLib. Since this is before library contructors
+  // are called, we must use a loop rather than SetMem.
+  //
+  Table = (UINT8*)(UINTN)FixedPcdGet64 (PcdGuidedExtractHandlerTableAddress);
+  for (Index = 0;
+   Index < FixedPcdGet32 (PcdGuidedExtractHandlerTableSize);
+   ++Index) {
+Table[Index] = 0;
+  }
 
   ProcessLibraryConstructorList (NULL, NULL);
 
-- 
1.8.3.1


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


Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

2015-11-26 Thread Laszlo Ersek
On 11/27/15 02:14, Yao, Jiewen wrote:
> Hi Laszlo
> Comments below:
> 
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
> Ersek
> Sent: Friday, November 27, 2015 5:57 AM
> To: Yao, Jiewen; Kinney, Michael D; edk2-de...@ml01.01.org
> Cc: Paolo Bonzini; Fan, Jeff
> Subject: Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
> 
> On 11/25/15 22:56, Yao, Jiewen wrote:
>> Hi Mike
>> Thanks for the suggestion.
>> Previously, I just want to *ADD* without touch old logic. I will use your 
>> way to do it.
>>
>> -Original Message-
>> From: Kinney, Michael D
>> Sent: Thursday, November 26, 2015 2:01 AM
>> To: Yao, Jiewen; edk2-de...@ml01.01.org; Kinney, Michael D
>> Cc: Fan, Jeff
>> Subject: RE: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
>>
>> Jiewen,
>>
>> For IA32 assembly, can we combine into a single OR instruction that sets 
>> both page enable and WP?
>> For X64, does it make sense to use single OR instruction instead of 2 BTS 
>> instructions as well?
>>
>> With those updates,
>>
>> Reviewed-by: Michael Kinney 
>>
>> Thanks,
>>
>> Mike
>>
>>> -Original Message-
>>> From: Yao, Jiewen
>>> Sent: Wednesday, November 25, 2015 4:35 AM
>>> To: edk2-de...@ml01.01.org
>>> Cc: Yao, Jiewen ; Fan, Jeff 
>>> ; Kinney, Michael D 
>>> Subject: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
>>>
>>> So that we can use write-protection for code later.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: "Yao, Jiewen" 
>>> Cc: "Fan, Jeff" 
>>> Cc: "Kinney, Michael D" 
>>> ---
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S   | 1 +
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 1 +
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S| 1 +
>>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm  | 1 +
>>>  4 files changed, 4 insertions(+)
>>>
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S 
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> index 7e1787c..8e64ce8 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>>> @@ -142,6 +142,7 @@ L13:
>>>
>>>  movl%cr0, %ebx
>>>  orl $0x08000, %ebx # enable paging
>>> +orl $0x1, %ebx # set WP
>>>  movl%ebx, %cr0
>>>  lealDSC_OFFSET(%edi),%ebx
>>>  movwDSC_DS(%ebx),%ax
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm 
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> index e6af344..a955785 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>>> @@ -148,6 +148,7 @@ gSmiCr3 DD  ?
>>>
>>>  mov ebx, cr0
>>>  or  ebx, 08000h ; enable paging
>>> +or  ebx, 1h ; set WP
>>>  mov cr0, ebx
>>>  lea ebx, [edi + DSC_OFFSET]
>>>  mov ax, [ebx + DSC_DS]
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S 
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> index 1d40819..8050a00 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>>> @@ -163,6 +163,7 @@ NxeDone:
>>>  wrmsr
>>>  movq%cr0, %rbx
>>>  btsl$31, %ebx
>>> +btsl$16, %ebx   # set WP
>>>  movq%rbx, %cr0
>>>  retf
>>>  LongMode:   # long mode (64-bit code) starts 
>>> here
>>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm 
>>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> index 6e1d3f1..db170d6 100644
>>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>>> @@ -159,6 +159,7 @@ Base:
>>>  wrmsr
>>>  mov rbx, cr0
>>>  bts ebx, 31
>>> +bts ebx, 16; set WP
>>>  mov cr0, rbx
>>>  retf
>>>  @LongMode:  ; long mode (64-bit code) starts 
>>> here
>>> --
>>> 1.9.5.msysgit.0
> 
> This patch (= SVN r18960) breaks the 32-bit (Ia32) build of the OVMF SMM 
> series.
> 
> KVM "rejects" the guest soon after the SMBASE relocation.
> 
> These are the last messages from the OVMF debug log:
> 
>> Loading SMM driver at 0x0007FFD2000 EntryPoint=0x0007FFD2253 
>> PiSmmCpuDxeSmm.efi SMRR Base: 0x7F80, SMRR Size: 0x80 
>> PcdCpuSmmCodeAccessCheckEnable = 1 SMRAM TileSize = 0x2000 
>> (0x1000, 0x1000) SMRAM SaveState Buffer (0x7FFC4000, 
>> 0xE000) CPU[000]  APIC ID=  SMBASE=7FFBC000  
>> SaveState=7FFCBC00  Size=0400 CPU[001]  APIC ID=0002  
>> SMBASE=7FFBE000  SaveState=7FFCDC00  Size=0400 CPU[002]  APIC 
>> ID=0003  SMBASE=7FFC  SaveState=7FFCFC00  Size=0400 CPU[003]  
>> APIC ID=0001  SMBASE=7FFC2000  SaveState=7FFD1C00  Size=0400
>> InstallProtocolInterface: 26EEB3DE-B689-492E-80F0-BE8BD7DA4BA7 
>> 7FFE0FD0 SMM IPL registered SMM Entry Point address 7FFF19AE
>> SmmInstallProto

Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

2015-11-26 Thread Yao, Jiewen
Hi Laszlo
Comments below:

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Laszlo 
Ersek
Sent: Friday, November 27, 2015 5:57 AM
To: Yao, Jiewen; Kinney, Michael D; edk2-de...@ml01.01.org
Cc: Paolo Bonzini; Fan, Jeff
Subject: Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

On 11/25/15 22:56, Yao, Jiewen wrote:
> Hi Mike
> Thanks for the suggestion.
> Previously, I just want to *ADD* without touch old logic. I will use your way 
> to do it.
> 
> -Original Message-
> From: Kinney, Michael D
> Sent: Thursday, November 26, 2015 2:01 AM
> To: Yao, Jiewen; edk2-de...@ml01.01.org; Kinney, Michael D
> Cc: Fan, Jeff
> Subject: RE: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
> 
> Jiewen,
> 
> For IA32 assembly, can we combine into a single OR instruction that sets both 
> page enable and WP?
> For X64, does it make sense to use single OR instruction instead of 2 BTS 
> instructions as well?
> 
> With those updates,
> 
> Reviewed-by: Michael Kinney 
> 
> Thanks,
> 
> Mike
> 
>> -Original Message-
>> From: Yao, Jiewen
>> Sent: Wednesday, November 25, 2015 4:35 AM
>> To: edk2-de...@ml01.01.org
>> Cc: Yao, Jiewen ; Fan, Jeff 
>> ; Kinney, Michael D 
>> Subject: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
>>
>> So that we can use write-protection for code later.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: "Yao, Jiewen" 
>> Cc: "Fan, Jeff" 
>> Cc: "Kinney, Michael D" 
>> ---
>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S   | 1 +
>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 1 +
>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S| 1 +
>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm  | 1 +
>>  4 files changed, 4 insertions(+)
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>> index 7e1787c..8e64ce8 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>> @@ -142,6 +142,7 @@ L13:
>>
>>  movl%cr0, %ebx
>>  orl $0x08000, %ebx # enable paging
>> +orl $0x1, %ebx # set WP
>>  movl%ebx, %cr0
>>  lealDSC_OFFSET(%edi),%ebx
>>  movwDSC_DS(%ebx),%ax
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>> index e6af344..a955785 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>> @@ -148,6 +148,7 @@ gSmiCr3 DD  ?
>>
>>  mov ebx, cr0
>>  or  ebx, 08000h ; enable paging
>> +or  ebx, 1h ; set WP
>>  mov cr0, ebx
>>  lea ebx, [edi + DSC_OFFSET]
>>  mov ax, [ebx + DSC_DS]
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>> index 1d40819..8050a00 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>> @@ -163,6 +163,7 @@ NxeDone:
>>  wrmsr
>>  movq%cr0, %rbx
>>  btsl$31, %ebx
>> +btsl$16, %ebx   # set WP
>>  movq%rbx, %cr0
>>  retf
>>  LongMode:   # long mode (64-bit code) starts 
>> here
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>> index 6e1d3f1..db170d6 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>> @@ -159,6 +159,7 @@ Base:
>>  wrmsr
>>  mov rbx, cr0
>>  bts ebx, 31
>> +bts ebx, 16; set WP
>>  mov cr0, rbx
>>  retf
>>  @LongMode:  ; long mode (64-bit code) starts 
>> here
>> --
>> 1.9.5.msysgit.0

This patch (= SVN r18960) breaks the 32-bit (Ia32) build of the OVMF SMM series.

KVM "rejects" the guest soon after the SMBASE relocation.

These are the last messages from the OVMF debug log:

> Loading SMM driver at 0x0007FFD2000 EntryPoint=0x0007FFD2253 
> PiSmmCpuDxeSmm.efi SMRR Base: 0x7F80, SMRR Size: 0x80 
> PcdCpuSmmCodeAccessCheckEnable = 1 SMRAM TileSize = 0x2000 
> (0x1000, 0x1000) SMRAM SaveState Buffer (0x7FFC4000, 
> 0xE000) CPU[000]  APIC ID=  SMBASE=7FFBC000  
> SaveState=7FFCBC00  Size=0400 CPU[001]  APIC ID=0002  
> SMBASE=7FFBE000  SaveState=7FFCDC00  Size=0400 CPU[002]  APIC 
> ID=0003  SMBASE=7FFC  SaveState=7FFCFC00  Size=0400 CPU[003]  
> APIC ID=0001  SMBASE=7FFC2000  SaveState=7FFD1C00  Size=0400
> InstallProtocolInterface: 26EEB3DE-B689-492E-80F0-BE8BD7DA4BA7 
> 7FFE0FD0 SMM IPL registered SMM Entry Point address 7FFF19AE
> SmmInstallProtocolInterface: EB346B97-975F-4A9F-8B22-F8E92BB3D569 
> 7FFE0F68
> SmmInstallProtocolInterface: 1D202CAB-C8AB-4D5C-94F7-3CFCC0D3D335 
> 7FFE0FDC SMM S3 SMRAM Structure = 7F5816C0 SMM S3 Str

Re: [edk2] [patch] UefiCpuPkg/CpuExceptionHandlerLib: Skip CR restore for SMM handler.

2015-11-26 Thread Fan, Jeff
Reviewed-by: Jeff Fan 

-Original Message-
From: Yao, Jiewen 
Sent: Thursday, November 26, 2015 8:34 PM
To: edk2-de...@ml01.01.org
Cc: Yao, Jiewen; Fan, Jeff; Kinney, Michael D
Subject: [patch] UefiCpuPkg/CpuExceptionHandlerLib: Skip CR restore for SMM 
handler.

In SMM, we skip CR restore. The CR should always be right and should no be 
touched.
mDoFarReturnFlag is changed to mSmmFlag to indicate all difference between 
normal mode and SMM.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" 
Cc: "Fan, Jeff" 
Cc: "Kinney, Michael D" 
---
 .../Library/CpuExceptionHandlerLib/CpuExceptionCommon.h   |  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c  |  2 +-
 .../CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S | 14 --
 .../CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm   | 14 --
 .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   |  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c  |  2 +-
 .../CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S  | 15 +--
 .../CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm| 14 --
 8 files changed, 53 insertions(+), 12 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index b28e9c5..9fc0bd5 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -42,7 +42,7 @@ typedef struct {
 
 extern CONST UINT32mErrorCodeFlag;
 extern CONST UINTN mImageAlignSize;
-extern CONST UINTN mDoFarReturnFlag;
+extern CONST UINTN mSmmFlag;
 extern RESERVED_VECTORS_DATA   *mReservedVectors;
 
 /**
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
index 6739a2c..c11fb96 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 
-CONST UINTNmDoFarReturnFlag  = 0;
+CONST UINTNmSmmFlag  = 0;
 
 extern SPIN_LOCK   mDisplayMessageSpinLock;
 extern EFI_CPU_INTERRUPT_HANDLER   *mExternalInterruptHandler;
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S
index 3676809..8d65e76 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm
+++ .S
@@ -26,7 +26,7 @@ ASM_GLOBAL ASM_PFX(CommonInterruptEntry)  ASM_GLOBAL 
ASM_PFX(HookAfterStubHeaderEnd)
 
 #EXTRN ASM_PFX(mErrorCodeFlag):DWORD   # Error code flags for 
exceptions
-#EXTRN ASM_PFX(mDoFarReturnFlag):DWORD # Do far return flag
+#EXTRN ASM_PFX(mSmmFlag):DWORD # Is it handler for SMM?
 
 .text
 
@@ -456,6 +456,7 @@ ErrorCodeAndVectorOnStack:
 popl%ebx # retore value of ebx that was 
overwritten
  # by CPUID 
 movl%cr4, %eax
+movl%eax, %ecx
 pushl   %eax # push cr4 firstly
 testl   $BIT24, %edx # Test for FXSAVE/FXRESTOR support
 jz  L1
@@ -465,7 +466,10 @@ L1:
 jz  L2
 orl $BIT3, %eax  # Set CR4.DE
 L2:
+cmpl%ecx, %eax
+jz  Cr4Done
 movl%eax, %cr4
+Cr4Done:
 movl%cr3, %eax
 pushl   %eax
 movl%cr2, %eax
@@ -536,6 +540,11 @@ L4:
 #; or debuggers set breakpoint in interrupt/exception context
 addl$24, %esp
 
+cmpl$0, ASM_PFX(mSmmFlag)   # Check if need skip WriteCr
+jz  CrRestore
+addl$20, %esp
+jmp CrDone
+CrRestore:
 #; UINT32  Cr0, Cr1, Cr2, Cr3, Cr4;
 popl%eax
 movl%eax, %cr0
@@ -546,6 +555,7 @@ L4:
 movl%eax, %cr3
 popl%eax
 movl%eax, %cr4
+CrDone:
 
 #; UINT32  EFlags;
 popl20(%ebp)
@@ -595,7 +605,7 @@ ErrorCode:
 jmp *-12(%esp)
 
 DoReturn:
-cmpl$0, ASM_PFX(mDoFarReturnFlag)
+cmpl$0, ASM_PFX(mSmmFlag)
 jz  DoIret
 pushl   8(%esp)   # save EFLAGS
 addl$16, %esp
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm
index 12bbec0..177bdd9 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm
+++ .asm
@@ -31,7 +31,7 @@ CommonExceptionHandler PROTO   C
 .data
 
 EXTRN mErrorCodeFlag:DWORD; Error code flags for exceptions
-EXTRN mDoFarReturnFlag:DWORD  ; Do far return flag
+EXTRN mSmmFlag:DWORD  ; Is it handl

Re: [edk2] [patch] UefiCpuPkg/PiSmmCpu: Move IDT to page aligned memory.

2015-11-26 Thread Fan, Jeff
Move IDT table to C code is very good! 

I think EFIAPI is no longer required for InitializeIDTSmmStackGuard().

Reviewed-by: Jeff Fan 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of jiewen 
yao
Sent: Thursday, November 26, 2015 4:59 PM
To: edk2-de...@ml01.01.org
Cc: Kinney, Michael D; Yao, Jiewen; Fan, Jeff
Subject: [edk2] [patch] UefiCpuPkg/PiSmmCpu: Move IDT to page aligned memory.

The IDT in ASM is removed. We rely on C code to allocate IDT.
We also move InitializeIDTSmmStackGuard() from ASM to C file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" 
Cc: "Fan, Jeff" 
Cc: "Kinney, Michael D" 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S   | 224 +
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm |  34 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c   |  24 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c  |  13 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S| 249 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm  |  33 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c|  21 ++
 7 files changed, 72 insertions(+), 526 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S
index 4130bf5..eb41410 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S
@@ -24,6 +24,7 @@ ASM_GLOBAL  ASM_PFX(PageFaultStubFunction)  ASM_GLOBAL  
ASM_PFX(gSmiMtrrs)  ASM_GLOBAL  ASM_PFX(gcSmiIdtr)  ASM_GLOBAL  
ASM_PFX(gcSmiGdtr)
+ASM_GLOBAL  ASM_PFX(gTaskGateDescriptor)
 ASM_GLOBAL  ASM_PFX(gcPsd)
 ASM_GLOBAL  ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable))
 
@@ -236,207 +237,10 @@ ASM_PFX(gcPsd):
 ASM_PFX(gcSmiGdtr):  .word  GDT_SIZE - 1
  .long  NullSeg
 
-ASM_PFX(gcSmiIdtr):  .word  IDT_SIZE - 1
- .long  _SmiIDT
-
-_SmiIDT:
-# The following segment repeats 32 times:
-# No. 1
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 2
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 3
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 4
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 5
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 6
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 7
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 8
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 9
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 10
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 11
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 12
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 

Re: [edk2] [PATCH v4 41/41] OvmfPkg: README: document SMM status

2015-11-26 Thread Laszlo Ersek
On 11/26/15 17:17, Laszlo Ersek wrote:
> On 11/25/15 22:29, Jordan Justen wrote:
>> On 2015-11-25 10:06:03, Laszlo Ersek wrote:
>>> On 11/25/15 18:46, Jordan Justen wrote:
 On 2015-11-03 13:01:17, Laszlo Ersek wrote:

> +  qemu-system-i386 -cpu coreduo,-nx \

 Sometimes we put '$' before a command prompt. I know there is no
 standard prompt, but that is the one that I usually use in examples.
>>>
>>> Hm, I'm not really consistent on that. When I paste a command line
>>> mainly for illustration, I do use $. When I expect people to actually
>>> paste the example / snippet into a script, or at the shell prompt
>>> directly, then $ just gets in the way of easy line selection. I think in
>>> this case I'd prefer to omit the dollar sign. But, you can convince me.
>>
>> It can get in the way if you just want to copy/paste several commands
>> to run right away. I don't think that is the case here. It is just one
>> command, and it is going to at least take two copy/pastes regardless.
>> I'm not real concerned about this either way.
> 
> Okay, I'll add the dollar sign to the lines where the binaries are entered.
> 
>>

> +
> +Dependent on the development status of the
> +"UefiCpuPkg/Universal/Acpi/S3Resume2Pei" module, S3 resume may not work 
> in
> +OvmfPkg/OvmfPkgX64.dsc builds. In such cases, OvmfPkg/OvmfPkgIa32X64.dsc 
> is
> +recommended for running X64 guests.

 Is this paragraph needed?
>>>
>>> I do think so. People (me included) tend to build the X64 DSC, unless
>>> advised otherwie.
>>
>> Yeah. The order of relavence is definitely X64, then IA32, then
>> IA32+X64.
>>
>>>
 I don't think we should have to say that
 UefiCpuPkg/S3Resume2Pei might be broken. Is it still broken?
>>>
>>> I believe so, yes. Jiewen outlined a number of changes required for the
>>> PEIM:
>>>
>>> http://thread.gmane.org/gmane.comp.bios.edk2.devel/3509/focus=3523
>>>
>>
>> It sounds like we should have the X64 dsc generate a build error with
>> SMM_REQUIRED until this is fixed. Maybe that can take the place of
>> this comment in the README?
> 
> I disagree with the build error. The X64 SMM_REQUIRE build can work
> perfectly fine if you disable S3 in QEMU (that is: dynamically, on the
> command line), or if you do enable S3, but never suspend & resume the guest.
> 
> This README patch names the option separately that controls S3 ("-global
> ICH9-LPC.disable_s3=[01]").
> 
> In fact, we (Red Hat) don't support the S3 enabled case (speaking
> unofficially -- this has varied over time). It tends to expose bugs in
> various components (like guest OS-level drivers).
> 
> The protection that SMM gives (... is supposed to give) to the variable
> driver stack is still worthwhile, with S3 disabled.
> 
>> Jiewen, Mike, do you have a plan for solving the X64 PEI
>> incompatibility?
> 
> That would be nice, yes, but I don't think it should delay this series
> even longer. As far as I understand, no Intel firmware that is released
> for physical machines *and* uses SMM builds the module for 64-bit. So
> that would be a first. I'm not sure what testing could be done outside
> of OVMF, which might delay this even longer.
> 
> Why are you against this paragraph in the README?

Anyway, since you gave your R-b for this patch, I'm going to pick it up,
and address all of your remarks, except the one about this paragraph --
I think it is prudent to keep it. It is very easy to remove it when the
time comes, and I will very likely notice any changes to S3Resume2Pei in
a timely manner (because I always skim fresh commits).

Thanks
Laszlo

> 
> Thanks
> Laszlo
> 
>>
>> -Jordan
>>
>>> This was on Oct 28th.
>>>
>>> And, whenever I fetch new commits from SVN, I always skim them quickly,
>>> before I rebase my local branches on top, so I know what to expect and
>>> what patches to edit (possibly) during the rebase. I don't recall any
>>> related changes for S3Resume2Pei.
>>>
>>> But, it's not hard to check at once:
>>>
>>> $ git log -1 UefiCpuPkg/Universal/Acpi/S3Resume2Pei
>>>
>>> commit c1fd37cd6bcb98143bd4a44f427735a748058ad8
>>> Author: Hao Wu 
>>> Date:   Mon Jul 13 01:24:24 2015 +
>>>
>>> UefiCpuPkg S3Resume2Pei: Fix ASSERT in WriteToOsS3PerformanceData
>>>
>>> That is, July 2015.
>>>
>>> So yeah, we do need this hint in the README. We can remove it later.
>>>
 Reviewed-by: Jordan Justen 
>>>
>>> I'll await your response before picking this up (for just the
>>> modifications that I agreed to above).
>>>
>>> Thanks!
>>> Laszlo
>>>

> +
>  === Network Support ===
>  
>  OVMF provides a UEFI network stack by default. Its lowest level driver 
> is the
> -- 
> 1.8.3.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
> h

[edk2] please DO NOT commit unreviewed patches to subversion!

2015-11-26 Thread Laszlo Ersek
I notice that recently there have been patches committed to the
subversion repository that had *never* been posted to the list, in the
ultimately committed form. Examples:

(1) Patches on the list:

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

[edk2] [patch 1/3] UefiCpuPkg/PiSmmCpu: Add 2 APIs in SmmCpuFeaturesLib.
[edk2] [patch 2/3] UefiCpuPkg/PiSmmCpu: Add NULL func for 2 new APIs in 
SmmCpuFeaturesLib.
[edk2] [patch 3/3] UefiCpuPkg/PiSmmCpu: Update function call for 2 new APIs 
in SmmCpuFeatureLib.

Committed patch (one patch!):

http://sourceforge.net/p/edk2/code/18958
Add 2 APIs in SmmCpuFeaturesLib.

The series that had been posted to the list, and reviewed there, in
a nice and structured way, got squashed into a single patch, and
commited that way.

(2) Patches on the list:

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

[edk2] [patch 1/2] UefiCpuPkg/PiSmmCpu: Always set RW+P bit for page table 
by default.
[edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

Committed patch (one patch!):

http://sourceforge.net/p/edk2/code/18960
Always set WP in CR0.

Exactly same treatment.

This practice abuses the trust of the community and makes patch review
*absolutely pointless*. Patches must be committed to SVN *exactly* the
way they were posted and reviewed, no ifs and buts, *unless* a reviewer
gives explicit license to fix up trivial stuff right before committing.

*Maybe* if a trivial conflict has to be fixed via a rebase -- because
some light changes have crept in, between receiving reviews and
committing -- than can be done, but even in that case, publicizing that
fact on the list is the minimally expected courtesy.

Squashing patches for committing is untolerable. It defeats the original
structuring, prevents bisection and bug hunt, and prevents retroactive
review and analysis.

If I post a 30-50 part series, should I then commit it all in a single
3000-5000 SLOC bomb? That practice is *exactly* what we've been trying
to extinguish!!!

People, I thought we were past this. Jesus I need some time off.

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


Re: [edk2] [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.

2015-11-26 Thread Laszlo Ersek
On 11/25/15 22:56, Yao, Jiewen wrote:
> Hi Mike
> Thanks for the suggestion.
> Previously, I just want to *ADD* without touch old logic. I will use your way 
> to do it.
> 
> -Original Message-
> From: Kinney, Michael D 
> Sent: Thursday, November 26, 2015 2:01 AM
> To: Yao, Jiewen; edk2-de...@ml01.01.org; Kinney, Michael D
> Cc: Fan, Jeff
> Subject: RE: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
> 
> Jiewen,
> 
> For IA32 assembly, can we combine into a single OR instruction that sets both 
> page enable and WP?
> For X64, does it make sense to use single OR instruction instead of 2 BTS 
> instructions as well?
> 
> With those updates,
> 
> Reviewed-by: Michael Kinney 
> 
> Thanks,
> 
> Mike
> 
>> -Original Message-
>> From: Yao, Jiewen
>> Sent: Wednesday, November 25, 2015 4:35 AM
>> To: edk2-de...@ml01.01.org
>> Cc: Yao, Jiewen ; Fan, Jeff ; 
>> Kinney, Michael D 
>> Subject: [patch 2/2] UefiCpuPkg/PiSmmCpu: Always set WP in CR0.
>>
>> So that we can use write-protection for code later.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: "Yao, Jiewen" 
>> Cc: "Fan, Jeff" 
>> Cc: "Kinney, Michael D" 
>> ---
>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S   | 1 +
>>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm | 1 +
>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S| 1 +
>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm  | 1 +
>>  4 files changed, 4 insertions(+)
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>> index 7e1787c..8e64ce8 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.S
>> @@ -142,6 +142,7 @@ L13:
>>
>>  movl%cr0, %ebx
>>  orl $0x08000, %ebx # enable paging
>> +orl $0x1, %ebx # set WP
>>  movl%ebx, %cr0
>>  lealDSC_OFFSET(%edi),%ebx
>>  movwDSC_DS(%ebx),%ax
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>> index e6af344..a955785 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.asm
>> @@ -148,6 +148,7 @@ gSmiCr3 DD  ?
>>
>>  mov ebx, cr0
>>  or  ebx, 08000h ; enable paging
>> +or  ebx, 1h ; set WP
>>  mov cr0, ebx
>>  lea ebx, [edi + DSC_OFFSET]
>>  mov ax, [ebx + DSC_DS]
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>> index 1d40819..8050a00 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
>> @@ -163,6 +163,7 @@ NxeDone:
>>  wrmsr
>>  movq%cr0, %rbx
>>  btsl$31, %ebx
>> +btsl$16, %ebx   # set WP
>>  movq%rbx, %cr0
>>  retf
>>  LongMode:   # long mode (64-bit code) starts 
>> here
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>> index 6e1d3f1..db170d6 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
>> @@ -159,6 +159,7 @@ Base:
>>  wrmsr
>>  mov rbx, cr0
>>  bts ebx, 31
>> +bts ebx, 16; set WP
>>  mov cr0, rbx
>>  retf
>>  @LongMode:  ; long mode (64-bit code) starts 
>> here
>> --
>> 1.9.5.msysgit.0

This patch (= SVN r18960) breaks the 32-bit (Ia32) build of the OVMF SMM series.

KVM "rejects" the guest soon after the SMBASE relocation.

These are the last messages from the OVMF debug log:

> Loading SMM driver at 0x0007FFD2000 EntryPoint=0x0007FFD2253 
> PiSmmCpuDxeSmm.efi
> SMRR Base: 0x7F80, SMRR Size: 0x80
> PcdCpuSmmCodeAccessCheckEnable = 1
> SMRAM TileSize = 0x2000 (0x1000, 0x1000)
> SMRAM SaveState Buffer (0x7FFC4000, 0xE000)
> CPU[000]  APIC ID=  SMBASE=7FFBC000  SaveState=7FFCBC00  Size=0400
> CPU[001]  APIC ID=0002  SMBASE=7FFBE000  SaveState=7FFCDC00  Size=0400
> CPU[002]  APIC ID=0003  SMBASE=7FFC  SaveState=7FFCFC00  Size=0400
> CPU[003]  APIC ID=0001  SMBASE=7FFC2000  SaveState=7FFD1C00  Size=0400
> InstallProtocolInterface: 26EEB3DE-B689-492E-80F0-BE8BD7DA4BA7 7FFE0FD0
> SMM IPL registered SMM Entry Point address 7FFF19AE
> SmmInstallProtocolInterface: EB346B97-975F-4A9F-8B22-F8E92BB3D569 7FFE0F68
> SmmInstallProtocolInterface: 1D202CAB-C8AB-4D5C-94F7-3CFCC0D3D335 7FFE0FDC
> SMM S3 SMRAM Structure = 7F5816C0
> SMM S3 Structure = 7F80
> SMM CPU Module exit from SMRAM with EFI_SUCCESS
> SMM IPL closed SMRAM window

QEMU logs the following:

> KVM: entry failed, hardware error 0x8021
> 
> If you're running a guest on an Intel machine without unrestricted mode
> support, the failure can be most likely due to the guest entering an invalid
> state for Intel VT. 

Re: [edk2] [PATCH V4 07/13] CorebootPayloadPkg: Use SerialDxe in MdeModulePkg

2015-11-26 Thread Laszlo Ersek
On 11/26/15 18:39, Laszlo Ersek wrote:
> Hi Star,
> 
> On 11/25/15 02:33, Star Zeng wrote:
>> 1. Update fdf and dsc to use SerialDxe in MdeModulePkg.
>> 2. Separate the code that gets SerialRegBase and SerialRegAccessType
>>by CbParseLib from CorebootPayloadPkg/Library/SerialPortLib to
>>PlatformHookLib, and then leverage BaseSerialPortLib16550 in
>>MdeModulePkg.
>> 3. Remove CorebootPayloadPkg/SerialDxe and
>>CorebootPayloadPkg/Library/SerialPortLib.
>>
>> Cc: Michael D Kinney 
>> Cc: Liming Gao 
>> Cc: Maurice Ma 
>> Cc: Prince Agyeman 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Star Zeng 
>> Reviewed-by: Maurice Ma 
>> ---
>>  CorebootPayloadPkg/CorebootPayloadPkg.fdf  |   4 +-
>>  CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc  |  11 +-
>>  CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc   |  11 +-
>>  .../Library/PlatformBdsLib/BdsPlatform.h   |   5 +-
>>  .../Library/PlatformHookLib/PlatformHookLib.c  |  56 +++
>>  .../Library/PlatformHookLib/PlatformHookLib.inf|  38 ++
>>  .../Library/SerialPortLib/SerialPortLib.c  | 316 -
>>  .../Library/SerialPortLib/SerialPortLib.inf|  42 ---
>>  CorebootPayloadPkg/SerialDxe/SerialDxe.inf |  55 ---
>>  CorebootPayloadPkg/SerialDxe/SerialIo.c| 392 
>> -
>>  10 files changed, 114 insertions(+), 816 deletions(-)
>>  create mode 100644 
>> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c
>>  create mode 100644 
>> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
>>  delete mode 100644 CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.c
>>  delete mode 100644 
>> CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf
>>  delete mode 100644 CorebootPayloadPkg/SerialDxe/SerialDxe.inf
>>  delete mode 100644 CorebootPayloadPkg/SerialDxe/SerialIo.c
> 
> I'm not completely sure if this patch caused the breakage, but I got a 
> CorebootPayloadPkg build failure report, and I sort of guess this patch could 
> be the culprit.
> 
> The build error is as follows:
> 
>> In file included from :0:0:
>> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c: In function 
>> 'PlatformHookSerialPortInitialize':
>> Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib/DEBUG/AutoGen.h:31:102:
>>  error: right-hand operand of comma expression has no effect 
>> [-Werror=unused-value]
>>  #define _PCD_SET_MODE_BOOL_S_PcdSerialUseMmio(Value)  
>> ((_gPcd_BinaryPatch_PcdSerialUseMmio = (Value)), RETURN_SUCCESS)
>>  
>>  ^
>> MdePkg/Include/Library/PcdLib.h:687:45: note: in expansion of macro 
>> '_PCD_SET_MODE_BOOL_S_PcdSerialUseMmio'
>>  #define PcdSetBoolS(TokenName, Value)   
>> _PCD_SET_MODE_BOOL_S_##TokenName((Value))
>>  ^
>> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c:48:5: note: in 
>> expansion of macro 'PcdSetBoolS'
>>  PcdSetBoolS (PcdSerialUseMmio, TRUE);
>>  ^
>> Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib/DEBUG/AutoGen.h:31:102:
>>  error: right-hand operand of comma expression has no effect 
>> [-Werror=unused-value]
>>  #define _PCD_SET_MODE_BOOL_S_PcdSerialUseMmio(Value)  
>> ((_gPcd_BinaryPatch_PcdSerialUseMmio = (Value)), RETURN_SUCCESS)
>>  
>>  ^
>> MdePkg/Include/Library/PcdLib.h:687:45: note: in expansion of macro 
>> '_PCD_SET_MODE_BOOL_S_PcdSerialUseMmio'
>>  #define PcdSetBoolS(TokenName, Value)   
>> _PCD_SET_MODE_BOOL_S_##TokenName((Value))
>>  ^
>> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c:50:5: note: in 
>> expansion of macro 'PcdSetBoolS'
>>  PcdSetBoolS (PcdSerialUseMmio, FALSE);
>>  ^
>> Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib/DEBUG/AutoGen.h:39:110:
>>  error: right-hand operand of comma expression has no effect 
>> [-Werror=unused-value]
>>  #define _PCD_SET_MODE_64_S_PcdSerialRegisterBase(Value)  
>> ((_gPcd_BinaryPatch_PcdSerialRegisterBase = (Value)), RETURN_SUCCESS)
>>  
>>  ^
>> MdePkg/Include/Library/PcdLib.h:647:45: note: in expansion of macro 
>> '_PCD_SET_MODE_64_S_PcdSerialRegisterBase'
>>  #define PcdSet64S(TokenName, Value) _PCD_SET_MODE_64_S_##TokenName  
>>   ((Value))
>>  ^
>> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c:52:3: note: in 
>> expansion of macro 'PcdSet64S'
>>PcdSet64S (PcdSerialRegisterBase, (UINT64) SerialRegBase);
>>^
>> cc1: all warning

Re: [edk2] [PATCH V4 07/13] CorebootPayloadPkg: Use SerialDxe in MdeModulePkg

2015-11-26 Thread Laszlo Ersek
Hi Star,

On 11/25/15 02:33, Star Zeng wrote:
> 1. Update fdf and dsc to use SerialDxe in MdeModulePkg.
> 2. Separate the code that gets SerialRegBase and SerialRegAccessType
>by CbParseLib from CorebootPayloadPkg/Library/SerialPortLib to
>PlatformHookLib, and then leverage BaseSerialPortLib16550 in
>MdeModulePkg.
> 3. Remove CorebootPayloadPkg/SerialDxe and
>CorebootPayloadPkg/Library/SerialPortLib.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Maurice Ma 
> Cc: Prince Agyeman 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng 
> Reviewed-by: Maurice Ma 
> ---
>  CorebootPayloadPkg/CorebootPayloadPkg.fdf  |   4 +-
>  CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc  |  11 +-
>  CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc   |  11 +-
>  .../Library/PlatformBdsLib/BdsPlatform.h   |   5 +-
>  .../Library/PlatformHookLib/PlatformHookLib.c  |  56 +++
>  .../Library/PlatformHookLib/PlatformHookLib.inf|  38 ++
>  .../Library/SerialPortLib/SerialPortLib.c  | 316 -
>  .../Library/SerialPortLib/SerialPortLib.inf|  42 ---
>  CorebootPayloadPkg/SerialDxe/SerialDxe.inf |  55 ---
>  CorebootPayloadPkg/SerialDxe/SerialIo.c| 392 
> -
>  10 files changed, 114 insertions(+), 816 deletions(-)
>  create mode 100644 
> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c
>  create mode 100644 
> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
>  delete mode 100644 CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.c
>  delete mode 100644 CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf
>  delete mode 100644 CorebootPayloadPkg/SerialDxe/SerialDxe.inf
>  delete mode 100644 CorebootPayloadPkg/SerialDxe/SerialIo.c

I'm not completely sure if this patch caused the breakage, but I got a 
CorebootPayloadPkg build failure report, and I sort of guess this patch could 
be the culprit.

The build error is as follows:

> In file included from :0:0:
> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c: In function 
> 'PlatformHookSerialPortInitialize':
> Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib/DEBUG/AutoGen.h:31:102:
>  error: right-hand operand of comma expression has no effect 
> [-Werror=unused-value]
>  #define _PCD_SET_MODE_BOOL_S_PcdSerialUseMmio(Value)  
> ((_gPcd_BinaryPatch_PcdSerialUseMmio = (Value)), RETURN_SUCCESS)
>   
> ^
> MdePkg/Include/Library/PcdLib.h:687:45: note: in expansion of macro 
> '_PCD_SET_MODE_BOOL_S_PcdSerialUseMmio'
>  #define PcdSetBoolS(TokenName, Value)   _PCD_SET_MODE_BOOL_S_##TokenName 
>((Value))
>  ^
> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c:48:5: note: in 
> expansion of macro 'PcdSetBoolS'
>  PcdSetBoolS (PcdSerialUseMmio, TRUE);
>  ^
> Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib/DEBUG/AutoGen.h:31:102:
>  error: right-hand operand of comma expression has no effect 
> [-Werror=unused-value]
>  #define _PCD_SET_MODE_BOOL_S_PcdSerialUseMmio(Value)  
> ((_gPcd_BinaryPatch_PcdSerialUseMmio = (Value)), RETURN_SUCCESS)
>   
> ^
> MdePkg/Include/Library/PcdLib.h:687:45: note: in expansion of macro 
> '_PCD_SET_MODE_BOOL_S_PcdSerialUseMmio'
>  #define PcdSetBoolS(TokenName, Value)   _PCD_SET_MODE_BOOL_S_##TokenName 
>((Value))
>  ^
> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c:50:5: note: in 
> expansion of macro 'PcdSetBoolS'
>  PcdSetBoolS (PcdSerialUseMmio, FALSE);
>  ^
> Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib/DEBUG/AutoGen.h:39:110:
>  error: right-hand operand of comma expression has no effect 
> [-Werror=unused-value]
>  #define _PCD_SET_MODE_64_S_PcdSerialRegisterBase(Value)  
> ((_gPcd_BinaryPatch_PcdSerialRegisterBase = (Value)), RETURN_SUCCESS)
>   
> ^
> MdePkg/Include/Library/PcdLib.h:647:45: note: in expansion of macro 
> '_PCD_SET_MODE_64_S_PcdSerialRegisterBase'
>  #define PcdSet64S(TokenName, Value) _PCD_SET_MODE_64_S_##TokenName   
>  ((Value))
>  ^
> CorebootPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c:52:3: note: in 
> expansion of macro 'PcdSet64S'
>PcdSet64S (PcdSerialRegisterBase, (UINT64) SerialRegBase);
>^
> cc1: all warnings being treated as errors
> GNUmakefile:299: recipe for target 
> 'Build/CorebootPayloadPkgIA32/DEBUG_GCC49/IA32/CorebootPayloadPkg/Library/PlatformHo

Re: [edk2] EDK python script

2015-11-26 Thread Laszlo Ersek
On 11/26/15 04:45, Lu, James wrote:
> 
> Hi,
> 
> I'm trying to build EDK BIOS with python script on Linux but got below error.
> 
> [16:50:59]W:  [Step 2/5] Build environment: 
> Linux-3.2.0-69-generic-x86_64-with-Ubuntu-12.04-precise
> [16:50:59]W:  [Step 2/5] Build start time: 16:50:59, Nov.25 2015
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5] build.py...
> [16:50:59]W:  [Step 2/5]  : error C0DE: Unknown fatal error when 
> processing []
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5] (Please send email to 
> edk2-de...@lists.sourceforge.net for 
> help, attaching following call stack trace!)
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5] (Python 2.7.3 on linux2) Traceback (most recent 
> call last):
> [16:50:59]W:  [Step 2/5]   File 
> "/opt/TCAgent/work/ee2ead8eb710175b/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
>  line 2031, in Main
> [16:50:59]W:  [Step 2/5] MyBuild = Build(Target, Workspace, Option)
> [16:50:59]W:  [Step 2/5]   File 
> "/opt/TCAgent/work/ee2ead8eb710175b/BaseTools/BinWrappers/PosixLike/../../Source/Python/build/build.py",
>  line 761, in __init__
> [16:50:59]W:  [Step 2/5] self.Db = 
> WorkspaceDatabase(GlobalData.gDatabasePath, self.Reparse)
> [16:50:59]W:  [Step 2/5]   File 
> "/opt/TCAgent/work/ee2ead8eb710175b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py",
>  line 2814, in __init__
> [16:50:59]W:  [Step 2/5] self.Conn.execute("PRAGMA synchronous=OFF")
> [16:50:59]W:  [Step 2/5] DatabaseError: database disk image is malformed
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5]
> [16:50:59]W:  [Step 2/5] - Failed -
> [16:50:59]W:  [Step 2/5] Build end time: 16:50:59, Nov.25 2015
> [16:50:59]W:  [Step 2/5] Build total time: 00:00:00
> 
> Can you help?

After you provide the full build command line and the full output in
your next message, I'm unsure if I will be able to help.

However, with the above truncated output, and no command line, I'm sure
I can't help.

Laszlo

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


Re: [edk2] [PATCH 10/23] ArmVirtPkg/PrePi: remove global variable allocation from lowlevel init

2015-11-26 Thread Laszlo Ersek
On 11/26/15 13:10, Ard Biesheuvel wrote:
> Now that we dropped all ArmPlatformGlobalVariableLib dependencies,
> there is no longer a need to allocate and clear out the global
> variable region in the PrePi init code. So remove it.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S |  7 -
>  ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf |  3 --
>  ArmVirtPkg/PrePi/PrePi.c| 33 ++--
>  ArmVirtPkg/PrePi/PrePi.h|  1 -
>  4 files changed, 2 insertions(+), 42 deletions(-)
> 
> diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S 
> b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> index f0cf865b3c93..68049d5df2bf 100644
> --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
> @@ -158,16 +158,10 @@ _GetStackBase:
>cmp   x0, #1
>bne   _PrepareArguments
>  
> -_ReserveGlobalVariable:
> -  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x0)
> -  // InitializePrimaryStack($GlobalVariableSize, $Tmp1, $Tmp2)
> -  InitializePrimaryStack(x0, x1, x2)
> -
>  _PrepareArguments:
>mov   x0, x10
>mov   x1, x11
>mov   x2, x12
> -  mov   x3, sp
>  
>// Move sec startup address into a data register
>// Ensure we're jumping to FV version of the code (not boot remapped alias)
> @@ -177,7 +171,6 @@ _PrepareArguments:
>//x0 = MpId
>//x1 = UefiMemoryBase
>//x2 = StacksBase
> -  //x3 = GlobalVariableBase
>blr   x4
>  
>  _NeverReturn:
> diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf 
> b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> index 8a7a67c1b5d3..966f0185bbda 100755
> --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
> @@ -61,7 +61,6 @@ [Ppis]
>gArmMpCoreInfoPpiGuid
>  
>  [Guids]
> -  gArmGlobalVariableGuid
>gArmMpCoreInfoGuid
>  
>  [FeaturePcd]
> @@ -79,8 +78,6 @@ [FixedPcd]
>gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
>gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
>  
> -  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
> -
>gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
>  
>gArmPlatformTokenSpaceGuid.PcdCoreCount
> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
> index fe7612cec74b..c69cff249e80 100755
> --- a/ArmVirtPkg/PrePi/PrePi.c
> +++ b/ArmVirtPkg/PrePi/PrePi.c
> @@ -25,14 +25,10 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  
>  #include "PrePi.h"
>  #include "LzmaDecompress.h"
>  
> -// Not used when PrePi in run in XIP mode
> -UINTN mGlobalVariableBase = 0;
> -
>  EFI_STATUS
>  EFIAPI
>  ExtractGuidedSectionLibConstructor (
> @@ -45,23 +41,6 @@ LzmaDecompressLibConstructor (
>VOID
>);
>  
> -VOID
> -EFIAPI
> -BuildGlobalVariableHob (
> -  IN EFI_PHYSICAL_ADDRESS GlobalVariableBase,
> -  IN UINT32   GlobalVariableSize
> -  )
> -{
> -  ARM_HOB_GLOBAL_VARIABLE  *Hob;
> -
> -  Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof 
> (ARM_HOB_GLOBAL_VARIABLE));
> -  ASSERT(Hob != NULL);
> -
> -  CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
> -  Hob->GlobalVariableBase = GlobalVariableBase;
> -  Hob->GlobalVariableSize = GlobalVariableSize;
> -}
> -
>  EFI_STATUS
>  GetPlatformPpi (
>IN  EFI_GUID  *PpiGuid,
> @@ -90,7 +69,6 @@ VOID
>  PrePiMain (
>IN  UINTN UefiMemoryBase,
>IN  UINTN StacksBase,
> -  IN  UINTN GlobalVariableBase,
>IN  UINT64StartTimeStamp
>)
>  {
> @@ -133,9 +111,6 @@ PrePiMain (
>StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
>BuildStackHob (StacksBase, StacksSize);
>  
> -  // Declare the Global Variable HOB
> -  BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 
> (PcdPeiGlobalVariableSize));
> -
>//TODO: Call CpuPei as a library
>BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
>  
> @@ -174,8 +149,7 @@ VOID
>  CEntryPoint (
>IN  UINTN MpId,
>IN  UINTN UefiMemoryBase,
> -  IN  UINTN StacksBase,
> -  IN  UINTN GlobalVariableBase
> +  IN  UINTN StacksBase
>)
>  {
>UINT64   StartTimeStamp;
> @@ -199,10 +173,7 @@ CEntryPoint (
>// Enable Instruction Caches on all cores.
>ArmEnableInstructionCache ();
>  
> -  // Define the Global Variable region
> -  mGlobalVariableBase = GlobalVariableBase;
> -
> -  PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);
> +  PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
>  
>// DXE Core should always load and never return
>ASSERT (FALSE);
> diff --git a/ArmVirtPkg/PrePi/PrePi.h b/ArmVirtPkg/PrePi/PrePi.h
> index 15b91e49c9bd..9b828

Re: [edk2] [PATCH 04/23] ArmVirtPkg/ArmVirtQemu: move to ArmPkg version of PeiServicesTablePointerLib

2015-11-26 Thread Ard Biesheuvel
On 26 November 2015 at 17:45, Laszlo Ersek  wrote:
> On 11/26/15 13:10, Ard Biesheuvel wrote:
>> As pointed out by Eugene, the ArmPlatformPkg implementation of
>> PeiServicesTablePointerLib violates the PI sec, since it uses
>> ArmPlatformGlobalVariableLib to store the PEI services table pointer
>> rather than the thread ID cpu registers as the spec requires.
>>
>> So instead, move to the ArmPkg version of this library, which does
>> adhere to the PI spec.
>>
>> Reported-by: Eugene Cohen 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel 
>> ---
>>  ArmVirtPkg/ArmVirt.dsc.inc | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
>> index 8626919f3a2c..b3066d298009 100644
>> --- a/ArmVirtPkg/ArmVirt.dsc.inc
>> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
>> @@ -156,7 +156,7 @@ [LibraryClasses.common.SEC]
>>
>> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
>>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
>> -  
>> PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>> +  
>> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>>
>> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
>>
>>  [LibraryClasses.common.PEI_CORE]
>> @@ -173,7 +173,7 @@ [LibraryClasses.common.PEI_CORE]
>>
>> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
>>
>>
>> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
>> -  
>> PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>> +  
>> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>>
>> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>>
>>  [LibraryClasses.common.PEIM]
>> @@ -191,7 +191,7 @@ [LibraryClasses.common.PEIM]
>>
>> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
>>
>>
>> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
>> -  
>> PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>> +  
>> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>>
>> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>>
>>  [LibraryClasses.common.DXE_CORE]
>>
>
> Out of curiosity -- do you know why ArmPlatformPkg's (non-conformant)
> version had been written in the first place? Or was it the first
> implementation, and the (conformant) ArmPkg version came about second?
>

The ArmPkg version was contributed by Eugene himself in June 2011, but
the ArmPlatformPkg version predates that. So for some reason, the
existing code was never ported.

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


Re: [edk2] [PATCH 05/23] ArmVirtPkg: drop ArmPlatformGlobalVariableLib dependency

2015-11-26 Thread Laszlo Ersek
On 11/26/15 13:10, Ard Biesheuvel wrote:
> Now that all PeiServicesTablePointerLib and PrePiHobListPointerLib
> library dependencies in both ArmVirtQemu and ArmVirtXen are satisfied
> by implemenations that do not depend on ArmPlatformGlobalVariableLib,
> we can remove all mention of it from the various .dsc files.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmVirtPkg/ArmVirt.dsc.inc  | 4 
>  ArmVirtPkg/ArmVirtQemu.dsc  | 5 +
>  ArmVirtPkg/ArmVirtXen.dsc   | 1 -
>  ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 1 -
>  4 files changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index b3066d298009..a0a1c618 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -149,7 +149,6 @@ [LibraryClasses.common]
>  [LibraryClasses.common.SEC]
>PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
>
> ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
> -  
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
>  
>
> DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
>
> DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
> @@ -172,7 +171,6 @@ [LibraryClasses.common.PEI_CORE]
>
> UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
>
> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
>  
> -  
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
>
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>
> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>  
> @@ -190,7 +188,6 @@ [LibraryClasses.common.PEIM]
>
> UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
>
> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
>  
> -  
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
>
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>
> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>  
> @@ -210,7 +207,6 @@ [LibraryClasses.common.DXE_DRIVER]
>
> SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
>PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
>
> MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
> -  
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
>  
>  [LibraryClasses.common.UEFI_APPLICATION]
>
> UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
> diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> index 3e4dd229edb0..84dad40a28c3 100644
> --- a/ArmVirtPkg/ArmVirtQemu.dsc
> +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> @@ -233,10 +233,7 @@ [Components.common]
>#
># PEI Phase modules
>#
> -  ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf {
> -
> -  
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
> -  }
> +  ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
>MdeModulePkg/Core/Pei/PeiMain.inf
>MdeModulePkg/Universal/PCD/Pei/Pcd.inf
>ArmPlatformPkg/PlatformPei/PlatformPeim.inf
> diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
> index ac37cd2a4345..29c409f21b0f 100644
> --- a/ArmVirtPkg/ArmVirtXen.dsc
> +++ b/ArmVirtPkg/ArmVirtXen.dsc
> @@ -168,7 +168,6 @@ [Components.common]
>
> PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
>ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf
>
> MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
> -  
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
>
> SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf
>}
>  
> diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c 
> b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
> index e5536ecd8e28..666edb47ce97 100644
> --- a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
> +++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
> @@ -18,7 +18,6 @@
>  #include 
>  #include

Re: [edk2] [PATCH 04/23] ArmVirtPkg/ArmVirtQemu: move to ArmPkg version of PeiServicesTablePointerLib

2015-11-26 Thread Laszlo Ersek
On 11/26/15 13:10, Ard Biesheuvel wrote:
> As pointed out by Eugene, the ArmPlatformPkg implementation of
> PeiServicesTablePointerLib violates the PI sec, since it uses
> ArmPlatformGlobalVariableLib to store the PEI services table pointer
> rather than the thread ID cpu registers as the spec requires.
> 
> So instead, move to the ArmPkg version of this library, which does
> adhere to the PI spec.
> 
> Reported-by: Eugene Cohen 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmVirtPkg/ArmVirt.dsc.inc | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index 8626919f3a2c..b3066d298009 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -156,7 +156,7 @@ [LibraryClasses.common.SEC]
>
> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> -  
> PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> +  
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
>  
>  [LibraryClasses.common.PEI_CORE]
> @@ -173,7 +173,7 @@ [LibraryClasses.common.PEI_CORE]
>
> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
>  
>
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
> -  
> PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> +  
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>
> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>  
>  [LibraryClasses.common.PEIM]
> @@ -191,7 +191,7 @@ [LibraryClasses.common.PEIM]
>
> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
>  
>
> ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
> -  
> PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> +  
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>
> SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
>  
>  [LibraryClasses.common.DXE_CORE]
> 

Out of curiosity -- do you know why ArmPlatformPkg's (non-conformant)
version had been written in the first place? Or was it the first
implementation, and the (conformant) ArmPkg version came about second?

Reviewed-by: Laszlo Ersek 

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


Re: [edk2] [PATCH] ArmPlatformPkg/PrePeiCore: add missing entries to AArch64 vector table

2015-11-26 Thread Leif Lindholm
On Thu, Nov 26, 2015 at 04:20:00PM +0100, Ard Biesheuvel wrote:
> On 26 November 2015 at 16:09, Mark Rutland  wrote:
> > On Thu, Nov 26, 2015 at 04:06:40PM +0100, Ard Biesheuvel wrote:
> >> On 20 November 2015 at 13:46, Mark Rutland  wrote:
> >> > On Fri, Nov 20, 2015 at 01:39:26PM +0100, Ard Biesheuvel wrote:
> >> >> The PrePeiCore vector table for AArch64 mode is only half populated.
> >> >> However unlikely, if exceptions from lower exception levels are ever
> >> >> taken, they should be reported correctly, rather than causing a
> >> >> recursive undefined instruction fault on the zero padding that was
> >> >> introduced by commit SVN r18904 ("ArmPkg/ArmPlatformPkg: position
> >> >> vectors relative to base"). So add the missing entries, and wire
> >> >> them up to the default handler.
> >> >>
> >> >> Contributed-under: TianoCore Contribution Agreement 1.0
> >> >> Signed-off-by: Ard Biesheuvel 
> >> >
> >> > Acked-by: Mark Rutland 
> >> >
> >> > Mark.
> >> >
> >>
> >> Ping?
> >
> > Applied locally.
> >
> > Thanks,
> > Mark.
> >
> > p.s. I assume you're asking Leif to apply this upstream?
> >
> 
> Well, I can apply it myself, but not without his ack (or R-b, in fact)

Demands, demands :)
Reviewed-by: Leif Lindholm 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v4 41/41] OvmfPkg: README: document SMM status

2015-11-26 Thread Laszlo Ersek
On 11/25/15 22:29, Jordan Justen wrote:
> On 2015-11-25 10:06:03, Laszlo Ersek wrote:
>> On 11/25/15 18:46, Jordan Justen wrote:
>>> On 2015-11-03 13:01:17, Laszlo Ersek wrote:
>>>
 +  qemu-system-i386 -cpu coreduo,-nx \
>>>
>>> Sometimes we put '$' before a command prompt. I know there is no
>>> standard prompt, but that is the one that I usually use in examples.
>>
>> Hm, I'm not really consistent on that. When I paste a command line
>> mainly for illustration, I do use $. When I expect people to actually
>> paste the example / snippet into a script, or at the shell prompt
>> directly, then $ just gets in the way of easy line selection. I think in
>> this case I'd prefer to omit the dollar sign. But, you can convince me.
> 
> It can get in the way if you just want to copy/paste several commands
> to run right away. I don't think that is the case here. It is just one
> command, and it is going to at least take two copy/pastes regardless.
> I'm not real concerned about this either way.

Okay, I'll add the dollar sign to the lines where the binaries are entered.

> 
>>>
 +
 +Dependent on the development status of the
 +"UefiCpuPkg/Universal/Acpi/S3Resume2Pei" module, S3 resume may not work in
 +OvmfPkg/OvmfPkgX64.dsc builds. In such cases, OvmfPkg/OvmfPkgIa32X64.dsc 
 is
 +recommended for running X64 guests.
>>>
>>> Is this paragraph needed?
>>
>> I do think so. People (me included) tend to build the X64 DSC, unless
>> advised otherwie.
> 
> Yeah. The order of relavence is definitely X64, then IA32, then
> IA32+X64.
> 
>>
>>> I don't think we should have to say that
>>> UefiCpuPkg/S3Resume2Pei might be broken. Is it still broken?
>>
>> I believe so, yes. Jiewen outlined a number of changes required for the
>> PEIM:
>>
>> http://thread.gmane.org/gmane.comp.bios.edk2.devel/3509/focus=3523
>>
> 
> It sounds like we should have the X64 dsc generate a build error with
> SMM_REQUIRED until this is fixed. Maybe that can take the place of
> this comment in the README?

I disagree with the build error. The X64 SMM_REQUIRE build can work
perfectly fine if you disable S3 in QEMU (that is: dynamically, on the
command line), or if you do enable S3, but never suspend & resume the guest.

This README patch names the option separately that controls S3 ("-global
ICH9-LPC.disable_s3=[01]").

In fact, we (Red Hat) don't support the S3 enabled case (speaking
unofficially -- this has varied over time). It tends to expose bugs in
various components (like guest OS-level drivers).

The protection that SMM gives (... is supposed to give) to the variable
driver stack is still worthwhile, with S3 disabled.

> Jiewen, Mike, do you have a plan for solving the X64 PEI
> incompatibility?

That would be nice, yes, but I don't think it should delay this series
even longer. As far as I understand, no Intel firmware that is released
for physical machines *and* uses SMM builds the module for 64-bit. So
that would be a first. I'm not sure what testing could be done outside
of OVMF, which might delay this even longer.

Why are you against this paragraph in the README?

Thanks
Laszlo

> 
> -Jordan
> 
>> This was on Oct 28th.
>>
>> And, whenever I fetch new commits from SVN, I always skim them quickly,
>> before I rebase my local branches on top, so I know what to expect and
>> what patches to edit (possibly) during the rebase. I don't recall any
>> related changes for S3Resume2Pei.
>>
>> But, it's not hard to check at once:
>>
>> $ git log -1 UefiCpuPkg/Universal/Acpi/S3Resume2Pei
>>
>> commit c1fd37cd6bcb98143bd4a44f427735a748058ad8
>> Author: Hao Wu 
>> Date:   Mon Jul 13 01:24:24 2015 +
>>
>> UefiCpuPkg S3Resume2Pei: Fix ASSERT in WriteToOsS3PerformanceData
>>
>> That is, July 2015.
>>
>> So yeah, we do need this hint in the README. We can remove it later.
>>
>>> Reviewed-by: Jordan Justen 
>>
>> I'll await your response before picking this up (for just the
>> modifications that I agreed to above).
>>
>> Thanks!
>> Laszlo
>>
>>>
 +
  === Network Support ===
  
  OVMF provides a UEFI network stack by default. Its lowest level driver is 
 the
 -- 
 1.8.3.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] ArmPlatformPkg/PrePeiCore: add missing entries to AArch64 vector table

2015-11-26 Thread Ard Biesheuvel
On 26 November 2015 at 16:09, Mark Rutland  wrote:
> On Thu, Nov 26, 2015 at 04:06:40PM +0100, Ard Biesheuvel wrote:
>> On 20 November 2015 at 13:46, Mark Rutland  wrote:
>> > On Fri, Nov 20, 2015 at 01:39:26PM +0100, Ard Biesheuvel wrote:
>> >> The PrePeiCore vector table for AArch64 mode is only half populated.
>> >> However unlikely, if exceptions from lower exception levels are ever
>> >> taken, they should be reported correctly, rather than causing a
>> >> recursive undefined instruction fault on the zero padding that was
>> >> introduced by commit SVN r18904 ("ArmPkg/ArmPlatformPkg: position
>> >> vectors relative to base"). So add the missing entries, and wire
>> >> them up to the default handler.
>> >>
>> >> Contributed-under: TianoCore Contribution Agreement 1.0
>> >> Signed-off-by: Ard Biesheuvel 
>> >
>> > Acked-by: Mark Rutland 
>> >
>> > Mark.
>> >
>>
>> Ping?
>
> Applied locally.
>
> Thanks,
> Mark.
>
> p.s. I assume you're asking Leif to apply this upstream?
>

Well, I can apply it myself, but not without his ack (or R-b, in fact)

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


Re: [edk2] [PATCH] ArmPlatformPkg/PrePeiCore: add missing entries to AArch64 vector table

2015-11-26 Thread Mark Rutland
On Thu, Nov 26, 2015 at 04:06:40PM +0100, Ard Biesheuvel wrote:
> On 20 November 2015 at 13:46, Mark Rutland  wrote:
> > On Fri, Nov 20, 2015 at 01:39:26PM +0100, Ard Biesheuvel wrote:
> >> The PrePeiCore vector table for AArch64 mode is only half populated.
> >> However unlikely, if exceptions from lower exception levels are ever
> >> taken, they should be reported correctly, rather than causing a
> >> recursive undefined instruction fault on the zero padding that was
> >> introduced by commit SVN r18904 ("ArmPkg/ArmPlatformPkg: position
> >> vectors relative to base"). So add the missing entries, and wire
> >> them up to the default handler.
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.0
> >> Signed-off-by: Ard Biesheuvel 
> >
> > Acked-by: Mark Rutland 
> >
> > Mark.
> >
> 
> Ping?

Applied locally.

Thanks,
Mark.

p.s. I assume you're asking Leif to apply this upstream?

> 
> >> ---
> >>  ArmPlatformPkg/PrePeiCore/AArch64/Exception.S | 40 
> >>  1 file changed, 40 insertions(+)
> >>
> >> diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S 
> >> b/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S
> >> index b31854ced256..75cd98ff4863 100644
> >> --- a/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S
> >> +++ b/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S
> >> @@ -77,4 +77,44 @@ _DefaultSError_h:
> >>mov  x0, #EXCEPT_AARCH64_SERROR
> >>TO_HANDLER
> >>
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_SYNC)
> >> +_DefaultSyncExceptHandler_LowerA64:
> >> +  mov  x0, #EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_IRQ)
> >> +_DefaultIrq_LowerA64:
> >> +  mov  x0, #EXCEPT_AARCH64_IRQ
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_FIQ)
> >> +_DefaultFiq_LowerA64:
> >> +  mov  x0, #EXCEPT_AARCH64_FIQ
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_SERR)
> >> +_DefaultSError_LowerA64:
> >> +  mov  x0, #EXCEPT_AARCH64_SERROR
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_SYNC)
> >> +_DefaultSyncExceptHandler_LowerA32:
> >> +  mov  x0, #EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_IRQ)
> >> +_DefaultIrq_LowerA32:
> >> +  mov  x0, #EXCEPT_AARCH64_IRQ
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_FIQ)
> >> +_DefaultFiq_LowerA32:
> >> +  mov  x0, #EXCEPT_AARCH64_FIQ
> >> +  TO_HANDLER
> >> +
> >> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_SERR)
> >> +_DefaultSError_LowerA32:
> >> +  mov  x0, #EXCEPT_AARCH64_SERROR
> >> +  TO_HANDLER
> >> +
> >>  VECTOR_END(PeiVectorTable)
> >> --
> >> 1.9.1
> >>
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ArmPlatformPkg/PrePeiCore: add missing entries to AArch64 vector table

2015-11-26 Thread Ard Biesheuvel
On 20 November 2015 at 13:46, Mark Rutland  wrote:
> On Fri, Nov 20, 2015 at 01:39:26PM +0100, Ard Biesheuvel wrote:
>> The PrePeiCore vector table for AArch64 mode is only half populated.
>> However unlikely, if exceptions from lower exception levels are ever
>> taken, they should be reported correctly, rather than causing a
>> recursive undefined instruction fault on the zero padding that was
>> introduced by commit SVN r18904 ("ArmPkg/ArmPlatformPkg: position
>> vectors relative to base"). So add the missing entries, and wire
>> them up to the default handler.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel 
>
> Acked-by: Mark Rutland 
>
> Mark.
>

Ping?

>> ---
>>  ArmPlatformPkg/PrePeiCore/AArch64/Exception.S | 40 
>>  1 file changed, 40 insertions(+)
>>
>> diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S 
>> b/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S
>> index b31854ced256..75cd98ff4863 100644
>> --- a/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S
>> +++ b/ArmPlatformPkg/PrePeiCore/AArch64/Exception.S
>> @@ -77,4 +77,44 @@ _DefaultSError_h:
>>mov  x0, #EXCEPT_AARCH64_SERROR
>>TO_HANDLER
>>
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_SYNC)
>> +_DefaultSyncExceptHandler_LowerA64:
>> +  mov  x0, #EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_IRQ)
>> +_DefaultIrq_LowerA64:
>> +  mov  x0, #EXCEPT_AARCH64_IRQ
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_FIQ)
>> +_DefaultFiq_LowerA64:
>> +  mov  x0, #EXCEPT_AARCH64_FIQ
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A64_SERR)
>> +_DefaultSError_LowerA64:
>> +  mov  x0, #EXCEPT_AARCH64_SERROR
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_SYNC)
>> +_DefaultSyncExceptHandler_LowerA32:
>> +  mov  x0, #EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_IRQ)
>> +_DefaultIrq_LowerA32:
>> +  mov  x0, #EXCEPT_AARCH64_IRQ
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_FIQ)
>> +_DefaultFiq_LowerA32:
>> +  mov  x0, #EXCEPT_AARCH64_FIQ
>> +  TO_HANDLER
>> +
>> +VECTOR_ENTRY(PeiVectorTable, ARM_VECTOR_LOW_A32_SERR)
>> +_DefaultSError_LowerA32:
>> +  mov  x0, #EXCEPT_AARCH64_SERROR
>> +  TO_HANDLER
>> +
>>  VECTOR_END(PeiVectorTable)
>> --
>> 1.9.1
>>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] BaseTools: Add a VPD report subsection of FLASH to the Report

2015-11-26 Thread Yonghong Zhu
Build Spec already added a VPD report subsection of FLASH to the Report
chapter, it provide a simple way for user to determine where the VPD
region and VPD PCDs are located in the fd file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu 
---
 Source/Python/build/BuildReport.py | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/Source/Python/build/BuildReport.py 
b/Source/Python/build/BuildReport.py
index bf5bb8f..38e55f3 100644
--- a/Source/Python/build/BuildReport.py
+++ b/Source/Python/build/BuildReport.py
@@ -1385,10 +1385,36 @@ class FdReport(object):
 def __init__(self, Fd, Wa):
 self.FdName = Fd.FdUiName
 self.BaseAddress = Fd.BaseAddress
 self.Size = Fd.Size
 self.FdRegionList = [FdRegionReport(FdRegion, Wa) for FdRegion in 
Fd.RegionList]
+self.FvPath = os.path.join(Wa.BuildDir, "FV")
+self.VpdFilePath = os.path.join(self.FvPath, "%s.map" % 
Wa.Platform.VpdToolGuid)
+VpdPcdToken = 'gEfiMdeModulePkgTokenSpaceGuid'
+VpdPcdName = 'PcdVpdBaseAddress'
+self.VPDInfoList = []
+for index, FdRegion in enumerate(Fd.RegionList):
+if (VpdPcdName, VpdPcdToken) == FdRegion.PcdOffset:
+self.VPDBaseAddress = self.FdRegionList[index].BaseAddress
+self.VPDSize = self.FdRegionList[index].Size
+break
+
+if os.path.isfile(self.VpdFilePath):
+fd = open(self.VpdFilePath, "r")
+Lines = fd.readlines()
+for Line in Lines:
+Line = Line.strip()
+if len(Line) == 0 or Line.startswith("#"):
+continue
+try:
+PcdName, SkuId, Offset, Size, Value = 
Line.split("#")[0].split("|")
+PcdName, SkuId, Offset, Size, Value = PcdName.strip(), 
SkuId.strip(), Offset.strip(), Size.strip(), Value.strip()
+Offset = '0x%08X' % (int(Offset, 16) + self.VPDBaseAddress)
+self.VPDInfoList.append("%s | %s | %s | %s | %s" % 
(PcdName, SkuId, Offset, Size, Value))
+except:
+EdkLogger.error("BuildReport", CODE_ERROR, "Fail to parse 
VPD information file %s" % self.VpdFilePath)
+fd.close()
 
 ##
 # Generate report for the firmware device.
 #
 # This function generates report for the firmware device.
@@ -1405,10 +1431,19 @@ class FdReport(object):
 if len(self.FdRegionList) > 0:
 FileWrite(File, gSectionSep)
 for FdRegionItem in self.FdRegionList:
 FdRegionItem.GenerateReport(File)
 
+if len(self.VPDInfoList) > 0:
+FileWrite(File, gSubSectionStart)
+FileWrite(File, "FD VPD Region")
+FileWrite(File, "Base Address:   0x%X" % self.VPDBaseAddress)
+FileWrite(File, "Size:   0x%X (%.0fK)" % 
(self.VPDSize, self.VPDSize / 1024.0))
+FileWrite(File, gSubSectionSep)
+for item in self.VPDInfoList:
+FileWrite(File, item)
+FileWrite(File, gSubSectionEnd)
 FileWrite(File, gSectionEnd)
 
 
 
 ##
-- 
2.6.1.windows.1

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


[edk2] [patch] UefiCpuPkg/CpuExceptionHandlerLib: Skip CR restore for SMM handler.

2015-11-26 Thread jiewen yao
In SMM, we skip CR restore. The CR should always be right
and should no be touched.
mDoFarReturnFlag is changed to mSmmFlag to indicate all
difference between normal mode and SMM.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" 
Cc: "Fan, Jeff" 
Cc: "Kinney, Michael D" 
---
 .../Library/CpuExceptionHandlerLib/CpuExceptionCommon.h   |  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c  |  2 +-
 .../CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S | 14 --
 .../CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm   | 14 --
 .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   |  2 +-
 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c  |  2 +-
 .../CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S  | 15 +--
 .../CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm| 14 --
 8 files changed, 53 insertions(+), 12 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index b28e9c5..9fc0bd5 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -42,7 +42,7 @@ typedef struct {
 
 extern CONST UINT32mErrorCodeFlag;
 extern CONST UINTN mImageAlignSize;
-extern CONST UINTN mDoFarReturnFlag;
+extern CONST UINTN mSmmFlag;
 extern RESERVED_VECTORS_DATA   *mReservedVectors;
 
 /**
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
index 6739a2c..c11fb96 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 
-CONST UINTNmDoFarReturnFlag  = 0;
+CONST UINTNmSmmFlag  = 0;
 
 extern SPIN_LOCK   mDisplayMessageSpinLock;
 extern EFI_CPU_INTERRUPT_HANDLER   *mExternalInterruptHandler;
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S
index 3676809..8d65e76 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.S
@@ -26,7 +26,7 @@ ASM_GLOBAL ASM_PFX(CommonInterruptEntry)
 ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd)
 
 #EXTRN ASM_PFX(mErrorCodeFlag):DWORD   # Error code flags for 
exceptions
-#EXTRN ASM_PFX(mDoFarReturnFlag):DWORD # Do far return flag
+#EXTRN ASM_PFX(mSmmFlag):DWORD # Is it handler for SMM?
 
 .text
 
@@ -456,6 +456,7 @@ ErrorCodeAndVectorOnStack:
 popl%ebx # retore value of ebx that was 
overwritten
  # by CPUID 
 movl%cr4, %eax
+movl%eax, %ecx
 pushl   %eax # push cr4 firstly
 testl   $BIT24, %edx # Test for FXSAVE/FXRESTOR support
 jz  L1
@@ -465,7 +466,10 @@ L1:
 jz  L2
 orl $BIT3, %eax  # Set CR4.DE
 L2:
+cmpl%ecx, %eax
+jz  Cr4Done
 movl%eax, %cr4
+Cr4Done:
 movl%cr3, %eax
 pushl   %eax
 movl%cr2, %eax
@@ -536,6 +540,11 @@ L4:
 #; or debuggers set breakpoint in interrupt/exception context
 addl$24, %esp
 
+cmpl$0, ASM_PFX(mSmmFlag)   # Check if need skip WriteCr
+jz  CrRestore
+addl$20, %esp
+jmp CrDone
+CrRestore:
 #; UINT32  Cr0, Cr1, Cr2, Cr3, Cr4;
 popl%eax
 movl%eax, %cr0
@@ -546,6 +555,7 @@ L4:
 movl%eax, %cr3
 popl%eax
 movl%eax, %cr4
+CrDone:
 
 #; UINT32  EFlags;
 popl20(%ebp)
@@ -595,7 +605,7 @@ ErrorCode:
 jmp *-12(%esp)
 
 DoReturn:
-cmpl$0, ASM_PFX(mDoFarReturnFlag)
+cmpl$0, ASM_PFX(mSmmFlag)
 jz  DoIret
 pushl   8(%esp)   # save EFLAGS
 addl$16, %esp
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm
index 12bbec0..177bdd9 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.asm
@@ -31,7 +31,7 @@ CommonExceptionHandler PROTO   C
 .data
 
 EXTRN mErrorCodeFlag:DWORD; Error code flags for exceptions
-EXTRN mDoFarReturnFlag:DWORD  ; Do far return flag
+EXTRN mSmmFlag:DWORD  ; Is it handler for SMM?
 
 .code
 
@@ -256,6 +256,7 @@ ErrorCodeAndVectorOnStack:
 ; are supported
 pop ebx ; retore value of ebx that was overwritten by CPUID 
 mov eax, cr4
+mov ecx, eax
 pusheax ; push cr4 firstly
 tes

[edk2] [PATCH 23/23] ArmPkg: remove SetPrimaryStack and InitializePrimaryStack macros

2015-11-26 Thread Ard Biesheuvel
The SetPrimaryStack and InitializePrimaryStack macros are no longer
used now that we removed support for ArmPlatformGlobalVariableLib.
So remove the various versions of them.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Include/AsmMacroIoLib.h   | 36 ---
 ArmPkg/Include/AsmMacroIoLib.inc | 38 
 ArmPkg/Include/AsmMacroIoLibV8.h | 35 --
 3 files changed, 109 deletions(-)

diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
index 6904bdc9b001..f94dcc619f7a 100644
--- a/ArmPkg/Include/AsmMacroIoLib.h
+++ b/ArmPkg/Include/AsmMacroIoLib.h
@@ -201,37 +201,6 @@ _InitializePrimaryStackEnd:
 #define LoadConstantToReg(Data, Reg) \
   ldr  Reg, =Data
 
-#define SetPrimaryStack(StackTop, GlobalSize, Tmp)  \
-  and Tmp, GlobalSize, #7 ; \
-  rsbne   Tmp, Tmp, #8; \
-  add GlobalSize, GlobalSize, Tmp ; \
-  sub sp, StackTop, GlobalSize; \
-  ; \
-  mov Tmp, sp ; \
-  mov GlobalSize, #0x0; \
-_SetPrimaryStackInitGlobals:  ; \
-  cmp Tmp, StackTop   ; \
-  beq _SetPrimaryStackEnd ; \
-  str GlobalSize, [Tmp], #4   ; \
-  b   _SetPrimaryStackInitGlobals ; \
-_SetPrimaryStackEnd:
-
-// Initialize the Global Variable with '0'
-#define InitializePrimaryStack(GlobalSize, Tmp1)\
-  and Tmp1, GlobalSize, #7; \
-  rsbne   Tmp1, Tmp1, #8  ; \
-  add GlobalSize, GlobalSize, Tmp1 ;\
-  ; \
-  mov Tmp1, sp; \
-  sub sp, GlobalSize  ; \
-  mov GlobalSize, #0x0; \
-_InitializePrimaryStackLoop:  ; \
-  cmp Tmp1, sp; \
-  bls _InitializePrimaryStackEnd  ; \
-  str GlobalSize, [Tmp1, #-4]!; \
-  b   _InitializePrimaryStackLoop ; \
-_InitializePrimaryStackEnd:
-
 #else
 
 //
@@ -293,11 +262,6 @@ _InitializePrimaryStackEnd:
 // conditional load testing eq flag
 #define LoadConstantToRegIfEq(Data, Reg)  LoadConstantToRegIfEqMacro Data, Reg
 
-#define SetPrimaryStack(StackTop,GlobalSize,Tmp) SetPrimaryStack StackTop, 
GlobalSize, Tmp
-
-// Initialize the Global Variable with '0'
-#define InitializePrimaryStack(GlobalSize, Tmp1) InitializePrimaryStack 
GlobalSize, Tmp1
-
 #endif
 
 #endif
diff --git a/ArmPkg/Include/AsmMacroIoLib.inc b/ArmPkg/Include/AsmMacroIoLib.inc
index 301bd890ac4d..95dc640d6fc3 100644
--- a/ArmPkg/Include/AsmMacroIoLib.inc
+++ b/ArmPkg/Include/AsmMacroIoLib.inc
@@ -80,42 +80,4 @@
   ldr  $Reg, =($Data)
   MEND
 
-  ; The reserved place must be 8-bytes aligned for pushing 64-bit variable on 
the stack
-  ; Note: Global Size will be modified
-  MACRO
-  SetPrimaryStack $StackTop, $GlobalSize, $Tmp
-  and $Tmp, $GlobalSize, #7
-  rsbne   $Tmp, $Tmp, #8
-  add $GlobalSize, $GlobalSize, $Tmp
-  sub sp, $StackTop, $GlobalSize
-
-  ; Set all the global variables to 0
-  mov $Tmp, sp
-  mov $GlobalSize, #0x0
-_SetPrimaryStackInitGlobals
-  cmp $Tmp, $StackTop
-  beq _SetPrimaryStackEnd
-  str $GlobalSize, [$Tmp], #4
-  b   _SetPrimaryStackInitGlobals
-_SetPrimaryStackEnd
-  MEND
-
-  MACRO
-  InitializePrimaryStack $GlobalSize, $Tmp1
-  and $Tmp1, $GlobalSize, #7
-  rsbne   $Tmp1, $Tmp1, #8
-  add $GlobalSize, $GlobalSize, $Tmp1
-
-  mov $Tmp1, sp
-  sub sp, $GlobalSize
-  ; Set all the global variables to 0
-  mov $GlobalSize, #0x0
-_InitializePrimaryStackLoop
-  cmp $Tmp1, sp
-  bls _InitializePrimaryStackEnd
-  str $GlobalSize, [$Tmp1, #-4]!
-  b   _InitializePrimaryStackLoop
-_InitializePrimaryStackEnd
-  MEND
-
   END
diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h
index 2ee1081632ba..a9f8491bc922 100644
--- a/ArmPkg/Include/AsmMacroIoLibV8.h
+++ b/ArmPkg/Include/AsmMacroIoLibV8.h
@@ -18,41 +18,6 @@
 #ifndef __MACRO_IO_LIBV8_H__
 #define __MACRO_IO_LIBV8_H__
 
-#define SetPrimaryStack(StackTop, GlobalSize, Tmp, Tmp1)  \
-  andsTmp, GlobalSize, #15;   \
-  mov Tmp1, #16   ;   \
-  sub Tmp1, Tmp1, Tmp ;   \
-  cselTmp, Tmp1, Tmp, ne  ;   \
-  add GlobalSize, GlobalSize, Tmp ;   \
-  sub sp, StackTop, GlobalSize;   \
-  ;   \
-  mov Tmp, sp ;   \
-  mov GlobalSize, #0x0;   \
-_SetPrimaryStackInitG

[edk2] [PATCH 14/23] ArmPlatformPkg/Sec: remove global variable allocation from lowlevel init

2015-11-26 Thread Ard Biesheuvel
Now that we dropped all ArmPlatformGlobalVariableLib dependencies,
there is no longer a need to allocate and clear out the global
variable region in the PrePi init code. So remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Sec/AArch64/SecEntryPoint.S | 6 +-
 ArmPlatformPkg/Sec/Arm/SecEntryPoint.S | 6 +-
 ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm   | 6 +-
 ArmPlatformPkg/Sec/Sec.inf | 2 --
 4 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/ArmPlatformPkg/Sec/AArch64/SecEntryPoint.S 
b/ArmPlatformPkg/Sec/AArch64/SecEntryPoint.S
index 3512ccd84dd2..000b56f573e5 100644
--- a/ArmPlatformPkg/Sec/AArch64/SecEntryPoint.S
+++ b/ArmPlatformPkg/Sec/AArch64/SecEntryPoint.S
@@ -99,11 +99,7 @@ _SetupPrimaryCoreStack:
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), x2)
   add   x1, x1, x2
 
-  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), x2)
-
-  // The reserved space for global variable must be 8-bytes aligned for pushing
-  // 64-bit variable on the stack
-  SetPrimaryStack (x1, x2, x3, x4)
+  mov   sp, x1
   b _PrepareArguments
 
 _SetupSecondaryCoreStack:
diff --git a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S 
b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S
index 51b91b965d8b..73c264810e66 100644
--- a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S
+++ b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.S
@@ -81,11 +81,7 @@ _SetupPrimaryCoreStack:
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)
   add   r1, r1, r2
 
-  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)
-
-  // The reserved space for global variable must be 8-bytes aligned for pushing
-  // 64-bit variable on the stack
-  SetPrimaryStack (r1, r2, r3)
+  mov   sp, r1
   b _PrepareArguments
 
 _SetupSecondaryCoreStack:
diff --git a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm 
b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
index b30fab2141fe..c0cd41069991 100644
--- a/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
+++ b/ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
@@ -83,11 +83,7 @@ _SetupPrimaryCoreStack
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)
   add   r1, r1, r2
 
-  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)
-
-  // The reserved space for global variable must be 8-bytes aligned for pushing
-  // 64-bit variable on the stack
-  SetPrimaryStack (r1, r2, r3)
+  mov   sp, r1
   b _PrepareArguments
 
 _SetupSecondaryCoreStack
diff --git a/ArmPlatformPkg/Sec/Sec.inf b/ArmPlatformPkg/Sec/Sec.inf
index 7c6e7ffba1c6..7f7243f98f77 100644
--- a/ArmPlatformPkg/Sec/Sec.inf
+++ b/ArmPlatformPkg/Sec/Sec.inf
@@ -81,7 +81,5 @@ [FixedPcd.common]
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
 
-  gArmPlatformTokenSpaceGuid.PcdSecGlobalVariableSize
-
 [FixedPcd.ARM]
   gArmTokenSpaceGuid.PcdArmNsacr
-- 
1.9.1

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


[edk2] [PATCH 22/23] ArmPlatformPkg: remove ArmGlobalVariable PCD, GUID and PPI definitions

2015-11-26 Thread Ard Biesheuvel
Now that we removed all references to the ArmGlobalVariable definitions
in the various lowlevel PrePi and PrePeiCore init routines, and removed
the PPI and HOB references from PlatformPeim, it is time to say goodbye
to ArmGlobalVariable. So remove the includes and the .DEC declarations.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmPlatformPkg.dec  | 20 ---
 ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h | 51 --
 ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h | 55 
 3 files changed, 126 deletions(-)

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec 
b/ArmPlatformPkg/ArmPlatformPkg.dec
index 8147db982727..e881c13439e4 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -38,15 +38,8 @@ [Guids.common]
   #
   gVariableRuntimeDxeFileGuid = { 0xcbd2e4d5, 0x7068, 0x4ff5, { 0xb4, 0x62, 
0x98, 0x22, 0xb4, 0xad, 0x8d, 0x60 } }
 
-  ## Include/Guid/ArmGlobalVariableHob.h
-  gArmGlobalVariableGuid  = { 0xc3253c90, 0xa24f, 0x4599, { 0xa6, 0x64, 
0x1f, 0x88, 0x13, 0x77, 0x8f, 0xc9} }
-
   gArmBootMonFsFileInfoGuid   = { 0x41e26b9c, 0xada6, 0x45b3, { 0x80, 0x8e, 
0x23, 0x57, 0xa3, 0x5b, 0x60, 0xd6 } }
 
-[Ppis]
-  ## Include/Ppi/ArmGlobalVariable.h
-  gArmGlobalVariablePpiGuid = { 0xab1c1816, 0xd542, 0x4e6f, {0x9b, 0x1e, 0x8e, 
0xcd, 0x92, 0x53, 0xe2, 0xe7} }
-
 [PcdsFeatureFlag.common]
   # Set this PCD to TRUE to map NORFlash at 0x0. FALSE means the DRAM is 
mapped at 0x0.
   gArmPlatformTokenSpaceGuid.PcdNorFlashRemapping|FALSE|BOOLEAN|0x0012
@@ -81,19 +74,6 @@ [PcdsFixedAtBuild.common]
   # Size of the region used by UEFI in permanent memory (Reserved 128MB by 
default)
   
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x0800|UINT32|0x0015
 
-  # Size to reserve in the primary core stack for PEI Global Variables
-  #  = sizeof(UINTN) /* PcdPeiServicePtr or HobListPtr */
-  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize|0x4|UINT32|0x0016
-  # PeiServicePtr and HobListPtr shares the same location in the PEI Global 
Variable list
-  # PeiServicePtr is only valid with PEI Core and HobListPtr only when the PEI 
Core is skipped.
-  ## TO BE REMOVED
-  ## 
ArmPlatformTokenSpaceGuid.PcdPeiServicePtrGlobalOffset|0x0|UINT32|0x0017
-  ## TO BE REMOVED
-  ## gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset|0x0|UINT32|0x0018
-
-  # Size to reserve in the primary core stack for SEC Global Variables
-  gArmPlatformTokenSpaceGuid.PcdSecGlobalVariableSize|0x0|UINT32|0x0031
-
   # Boot Monitor FileSystem
   
gArmPlatformTokenSpaceGuid.PcdBootMonFsSupportedDevicePaths|L""|VOID*|0x003A
 
diff --git a/ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h 
b/ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h
deleted file mode 100644
index 844090b4e8d1..
--- a/ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/** @file
-*
-*  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-*
-*  This program and the accompanying materials
-*  are licensed and made available under the terms and conditions of the BSD 
License
-*  which accompanies this distribution.  The full text of the license may be 
found at
-*  http://opensource.org/licenses/bsd-license.php
-*
-*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-*
-**/
-
-#ifndef __ARM_GLOBAL_VARIABLE_GUID_H__
-#define __ARM_GLOBAL_VARIABLE_GUID_H__
-
-#include 
-#include 
-
-#define ARM_HOB_GLOBAL_VARIABLE_GUID  \
-  { 0xc3253c90, 0xa24f, 0x4599, { 0xa6, 0x64, 0x1f, 0x88, 0x13, 0x77, 0x8f, 
0xc9} };
-
-extern EFI_GUID gArmGlobalVariableGuid;
-
-///
-/// Describes all memory ranges used during the HOB producer
-/// phase that exist outside the HOB list. This HOB type
-/// describes how memory is used, not the physical attributes of memory.
-///
-typedef struct {
-  ///
-  /// The Guid HOB header. Header.HobType = EFI_HOB_TYPE_GUID_EXTENSION
-  /// and  Header.Name= gArmGlobalVariableGuid
-  ///
-  EFI_HOB_GUID_TYPEHeader;
-
-  ///
-  /// The base address of memory allocated by this HOB. Type
-  /// EFI_PHYSICAL_ADDRESS is defined in AllocatePages() in the UEFI 2.0
-  /// specification.
-  ///
-  EFI_PHYSICAL_ADDRESSGlobalVariableBase;
-
-  ///
-  /// The length in bytes of memory allocated by this HOB.
-  ///
-  UINT32  GlobalVariableSize;
-} ARM_HOB_GLOBAL_VARIABLE;
-
-#endif
diff --git a/ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h 
b/ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h
deleted file mode 100644
index 8a29b8346530..
--- a/ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/** @file
-*
-*  Copyright (c) 2011, ARM Limited. All rights reserved.
-*
-*  This program and the accompanying materials
-*  are licensed and made 

[edk2] [PATCH 05/23] ArmVirtPkg: drop ArmPlatformGlobalVariableLib dependency

2015-11-26 Thread Ard Biesheuvel
Now that all PeiServicesTablePointerLib and PrePiHobListPointerLib
library dependencies in both ArmVirtQemu and ArmVirtXen are satisfied
by implemenations that do not depend on ArmPlatformGlobalVariableLib,
we can remove all mention of it from the various .dsc files.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirt.dsc.inc  | 4 
 ArmVirtPkg/ArmVirtQemu.dsc  | 5 +
 ArmVirtPkg/ArmVirtXen.dsc   | 1 -
 ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 1 -
 4 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index b3066d298009..a0a1c618 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -149,7 +149,6 @@ [LibraryClasses.common]
 [LibraryClasses.common.SEC]
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   
ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
 
   
DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
@@ -172,7 +171,6 @@ [LibraryClasses.common.PEI_CORE]
   
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
   
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   
SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
 
@@ -190,7 +188,6 @@ [LibraryClasses.common.PEIM]
   
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
   
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   
SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
 
@@ -210,7 +207,6 @@ [LibraryClasses.common.DXE_DRIVER]
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
 
 [LibraryClasses.common.UEFI_APPLICATION]
   
UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 3e4dd229edb0..84dad40a28c3 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -233,10 +233,7 @@ [Components.common]
   #
   # PEI Phase modules
   #
-  ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf {
-
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  }
+  ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
   MdeModulePkg/Core/Pei/PeiMain.inf
   MdeModulePkg/Universal/PCD/Pei/Pcd.inf
   ArmPlatformPkg/PlatformPei/PlatformPeim.inf
diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index ac37cd2a4345..29c409f21b0f 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -168,7 +168,6 @@ [Components.common]
   
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
   ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf
   
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
   
SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.inf
   }
 
diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c 
b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
index e5536ecd8e28..666edb47ce97 100644
--- a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
+++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 // Number of Virtual Memory Map Descriptors
-- 
1.9.1

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


[edk2] [PATCH 21/23] ArmPlatformPkg/PlatformIntelBdsLib: drop bogus gArmGlobalVariableGuid dep

2015-11-26 Thread Ard Biesheuvel
PlatformIntelBdsLib does not use gArmGlobalVariableGuid so drop
the declaration from the .inf.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf 
b/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
index 39df113288d2..daa0d91a2f76 100644
--- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
@@ -52,7 +52,6 @@ [LibraryClasses]
   GenericBdsLib
 
 [Guids]
-  gArmGlobalVariableGuid
   gEfiEndOfDxeEventGroupGuid
 
 [Pcd]
-- 
1.9.1

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


[edk2] [PATCH 17/23] ArmPlatformPkg/Bds: drop bogus ArmGlobalVariable dependencies

2015-11-26 Thread Ard Biesheuvel
Remove the GUID references to gArmGlobalVariableGuid and includes
of ArmGlobalVariableHob.h since they are not used by the ARM BDS.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Bds/Bds.inf  | 1 -
 ArmPlatformPkg/Bds/BootMenu.c   | 2 --
 ArmPlatformPkg/Bds/BootOption.c | 1 -
 3 files changed, 4 deletions(-)

diff --git a/ArmPlatformPkg/Bds/Bds.inf b/ArmPlatformPkg/Bds/Bds.inf
index 06e8d914fdc3..96bec16f0a2e 100644
--- a/ArmPlatformPkg/Bds/Bds.inf
+++ b/ArmPlatformPkg/Bds/Bds.inf
@@ -58,7 +58,6 @@ [LibraryClasses]
 [Guids]
   gEfiEndOfDxeEventGroupGuid
   gEfiFileSystemInfoGuid
-  gArmGlobalVariableGuid
   gFdtVariableGuid
 
 [Protocols]
diff --git a/ArmPlatformPkg/Bds/BootMenu.c b/ArmPlatformPkg/Bds/BootMenu.c
index 8caa3ce5ced7..5cbac1d2dc1a 100644
--- a/ArmPlatformPkg/Bds/BootMenu.c
+++ b/ArmPlatformPkg/Bds/BootMenu.c
@@ -14,8 +14,6 @@
 
 #include "BdsInternal.h"
 
-#include 
-
 #include 
 
 /**
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index bdd02b4ecda0..32a5679762f9 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -12,7 +12,6 @@
 *
 **/
 
-#include 
 #include "BdsInternal.h"
 
 EFI_STATUS
-- 
1.9.1

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


[edk2] [PATCH 16/23] ArmPkg/BdsLib: drop bogus gArmGlobalVariableGuid dependency

2015-11-26 Thread Ard Biesheuvel
The BdsLib implementation under ArmPkg never references
gArmGlobalVariableGuid so it should not list it as a dependency.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Library/BdsLib/BdsLib.inf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf
index eb4543eb2018..458fc66ff026 100644
--- a/ArmPkg/Library/BdsLib/BdsLib.inf
+++ b/ArmPkg/Library/BdsLib/BdsLib.inf
@@ -44,7 +44,6 @@ [LibraryClasses]
 
 [Guids]
   gEfiFileInfoGuid
-  gArmGlobalVariableGuid
 
 [Protocols]
   gEfiBdsArchProtocolGuid
-- 
1.9.1

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


[edk2] [PATCH 02/23] ArmPkg: remove ArmPlatformGlobalVariableLib resolution from ArmPkg.dsc

2015-11-26 Thread Ard Biesheuvel
ArmPkg does not depend on ArmPlatformGlobalVariableLib, and this library
is about to be removed, so remove all mention of it from ArmPkg.dsc.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/ArmPkg.dsc | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 1237eed65953..688244bd7c53 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -98,9 +98,6 @@ [LibraryClasses.common.PEIM]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
-[LibraryClasses.common.DXE_DRIVER]
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
-
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
 
-- 
1.9.1

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


[edk2] [PATCH 12/23] ArmPlatformPkg/PlatformPeim: remove ArmGlobalVariable lowlevel init

2015-11-26 Thread Ard Biesheuvel
Now that we dropped all ArmPlatformGlobalVariableLib dependencies,
there is no longer a need to query the ArmGlobalVariable PPI and install
the ArmGlobalVariable HOB. So remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/PlatformPei/PlatformPeim.c   | 33 
 ArmPlatformPkg/PlatformPei/PlatformPeim.inf |  6 
 2 files changed, 39 deletions(-)

diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.c 
b/ArmPlatformPkg/PlatformPei/PlatformPeim.c
index 58ecb31ec2fc..e4535250c245 100755
--- a/ArmPlatformPkg/PlatformPei/PlatformPeim.c
+++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.c
@@ -17,7 +17,6 @@
 //
 // The protocols, PPI and GUID defintions for this module
 //
-#include 
 #include 
 #include 
 #include 
@@ -32,8 +31,6 @@
 #include 
 #include 
 
-#include 
-
 EFI_STATUS
 EFIAPI
 InitializePlatformPeim (
@@ -62,24 +59,6 @@ CONST EFI_PEI_PPI_DESCRIPTOR  mPpiListRecoveryBootMode = {
   NULL
 };
 
-VOID
-EFIAPI
-BuildGlobalVariableHob (
-  IN EFI_PHYSICAL_ADDRESS GlobalVariableBase,
-  IN UINT32   GlobalVariableSize
-  )
-{
-  EFI_STATUSStatus;
-  ARM_HOB_GLOBAL_VARIABLE   *Hob;
-
-  Status = PeiServicesCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof 
(ARM_HOB_GLOBAL_VARIABLE), (VOID**)&Hob);
-  if (!EFI_ERROR(Status)) {
-CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
-Hob->GlobalVariableBase = GlobalVariableBase;
-Hob->GlobalVariableSize = GlobalVariableSize;
-  }
-}
-
 /*++
 
 Routine Description:
@@ -105,23 +84,11 @@ InitializePlatformPeim (
 {
   EFI_STATUSStatus;
   UINTN BootMode;
-  ARM_GLOBAL_VARIABLE_PPI   *ArmGlobalVariablePpi;
-  EFI_PHYSICAL_ADDRESS  GlobalVariableBase;
 
   DEBUG ((EFI_D_LOAD | EFI_D_INFO, "Platform PEIM Loaded\n"));
 
   PlatformPeim ();
 
-  Status = PeiServicesLocatePpi (&gArmGlobalVariablePpiGuid, 0, NULL, 
(VOID**)&ArmGlobalVariablePpi);
-  if (!EFI_ERROR(Status)) {
-Status = ArmGlobalVariablePpi->GetGlobalVariableMemory 
(&GlobalVariableBase);
-
-if (!EFI_ERROR(Status)) {
-  // Declare the Global Variable HOB
-  BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 
(PcdPeiGlobalVariableSize));
-}
-  }
-
   BootMode  = ArmPlatformGetBootMode ();
   Status= (**PeiServices).SetBootMode (PeiServices, (UINT8) BootMode);
   ASSERT_EFI_ERROR (Status);
diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf 
b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
index 3822b093503b..f466c1412ad3 100755
--- a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
+++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
@@ -47,10 +47,6 @@ [LibraryClasses]
 [Ppis]
   gEfiPeiMasterBootModePpiGuid  # PPI ALWAYS_PRODUCED
   gEfiPeiBootInRecoveryModePpiGuid  # PPI SOMETIMES_PRODUCED
-  gArmGlobalVariablePpiGuid
-
-[Guids]
-  gArmGlobalVariableGuid
 
 [FixedPcd]
   gArmTokenSpaceGuid.PcdFdBaseAddress
@@ -62,8 +58,6 @@ [FixedPcd]
   gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
   gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
 
-  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
-
 [Depex]
   TRUE
 
-- 
1.9.1

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


[edk2] [PATCH 13/23] ArmPlatformPkg/PrePeiCore: remove global variable allocation from lowlevel init

2015-11-26 Thread Ard Biesheuvel
Now that we dropped all ArmPlatformGlobalVariableLib dependencies,
there is no longer a need to allocate and clear out the global
variable region in the PrePeiCore init code. So remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S |  7 +-
 ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S |  7 +-
 ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm   |  7 +-
 ArmPlatformPkg/PrePeiCore/PrePeiCore.c   | 23 

 ArmPlatformPkg/PrePeiCore/PrePeiCore.h   |  5 -
 ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf   |  3 ---
 ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf  |  3 ---
 7 files changed, 3 insertions(+), 52 deletions(-)

diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S 
b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
index b84190cf3fd4..85d3450f62e4 100644
--- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
+++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
@@ -101,10 +101,5 @@ _PrepareArguments:
   blr   x3
 
 _SetupPrimaryCoreStack:
-  // x1 contains the top of the primary stack
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x2)
-
-  // The reserved space for global variable must be 16-bytes aligned for 
pushing
-  // 128-bit variable on the stack
-  SetPrimaryStack (x1, x2, x3, x4)
+  mov   sp, x1
   b _PrepareArguments
diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S 
b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
index a6f19aff0f8e..ba1bd09b67c7 100644
--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
@@ -82,12 +82,7 @@ _PrepareArguments:
   blx   r3
 
 _SetupPrimaryCoreStack:
-  // r1 contains the top of the primary stack
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
-
-  // The reserved space for global variable must be 8-bytes aligned for pushing
-  // 64-bit variable on the stack
-  SetPrimaryStack (r1, r2, r3)
+  mov   sp, r1
   b _PrepareArguments
 
 _NeverReturn:
diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm 
b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
index edf479ff43e5..c316379f0538 100644
--- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
+++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
@@ -84,12 +84,7 @@ _PrepareArguments
   blx   r3
 
 _SetupPrimaryCoreStack
-  // r1 contains the top of the primary stack
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
-
-  // The reserved space for global variable must be 8-bytes aligned for pushing
-  // 64-bit variable on the stack
-  SetPrimaryStack (r1, r2, r3)
+  mov   sp, r1
   b _PrepareArguments
 
 _NeverReturn
diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c 
b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c
index 491d7a6f851f..65b07b6d8941 100644
--- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c
+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c
@@ -17,23 +17,15 @@
 #include 
 #include 
 
-#include 
-
 #include "PrePeiCore.h"
 
 CONST EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI   mTemporaryRamSupportPpi = { 
PrePeiCoreTemporaryRamSupport };
-CONST ARM_GLOBAL_VARIABLE_PPI mGlobalVariablePpi = { 
PrePeiCoreGetGlobalVariableMemory };
 
 CONST EFI_PEI_PPI_DESCRIPTOR  gCommonPpiTable[] = {
   {
 EFI_PEI_PPI_DESCRIPTOR_PPI,
 &gEfiTemporaryRamSupportPpiGuid,
 (VOID *) &mTemporaryRamSupportPpi
-  },
-  {
-EFI_PEI_PPI_DESCRIPTOR_PPI,
-&gArmGlobalVariablePpiGuid,
-(VOID *) &mGlobalVariablePpi
   }
 };
 
@@ -146,18 +138,3 @@ PrePeiCoreTemporaryRamSupport (
 
   return EFI_SUCCESS;
 }
-
-EFI_STATUS
-PrePeiCoreGetGlobalVariableMemory (
-  OUT EFI_PHYSICAL_ADDRESS*GlobalVariableBase
-  )
-{
-  ASSERT (GlobalVariableBase != NULL);
-
-  *GlobalVariableBase = (UINTN)PcdGet64 (PcdCPUCoresStackBase) +
-(UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) -
-(UINTN)PcdGet32 (PcdPeiGlobalVariableSize);
-
-  return EFI_SUCCESS;
-}
-
diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h 
b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h
index 20684e2f904c..160894620ce4 100644
--- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h
+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h
@@ -40,11 +40,6 @@ PrePeiCoreTemporaryRamSupport (
   IN UINTNCopySize
   );
 
-EFI_STATUS
-PrePeiCoreGetGlobalVariableMemory (
-  OUT EFI_PHYSICAL_ADDRESS*GlobalVariableBase
-  );
-
 VOID
 SecSwitchStack (
   INTNStackDelta
diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf 
b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
index 5ba0231a3e4b..ecdbccb8d620 100644
--- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
@@ -59,7 +59,6 @@ [LibraryClasses]
 
 [Ppis]
   gEfiTemporaryRamSupportPpiGuid
-  gArmGlobalVari

[edk2] [PATCH 20/23] ArmPlatformPkg/EblCmdLib: drop bogus ArmGlobalVariableHob.h include

2015-11-26 Thread Ard Biesheuvel
EblCmdLib does not use anything that is declared by ArmGlobalVariableHob.h,
so remove the include.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c 
b/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c
index 8aae7b2c4e08..b0f6a72ee22d 100644
--- a/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c
+++ b/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c
@@ -26,7 +26,6 @@
 
 #include 
 
-#include 
 #include 
 
 #include 
-- 
1.9.1

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


[edk2] [PATCH 18/23] ArmPlatformPkg/ArmJunoDxe: drop bogus gArmGlobalVariableGuid dependency

2015-11-26 Thread Ard Biesheuvel
ArmJunoDxe does not use gArmGlobalVariableGuid so drop the declaration
from the .inf.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf 
b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
index 6157f9807faf..d1f2f7bada95 100644
--- a/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
+++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
@@ -52,7 +52,6 @@ [LibraryClasses]
   UefiDriverEntryPoint
 
 [Guids]
-  gArmGlobalVariableGuid
   gEfiEndOfDxeEventGroupGuid
   gEfiFileInfoGuid
 
-- 
1.9.1

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


[edk2] [PATCH 06/23] ArmPlatformPkg: move to ArmPkg version of PeiServicesTablePointerLib

2015-11-26 Thread Ard Biesheuvel
As pointed out by Eugene, the ArmPlatformPkg implementation of
PeiServicesTablePointerLib violates the PI sec, since it uses
ArmPlatformGlobalVariableLib to store the PEI services table pointer
rather than the thread ID cpu registers as the spec requires.

So instead, move to the ArmPkg version of this library, which does
adhere to the PI spec.

Reported-by: Eugene Cohen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmPlatformPkg.dsc | 4 ++--
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc 
b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 5b857e57af40..79004547bc56 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -163,7 +163,7 @@ [LibraryClasses.common.PEI_CORE]
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
   
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
 [LibraryClasses.common.PEIM]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@@ -179,7 +179,7 @@ [LibraryClasses.common.PEIM]
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
   
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
 
 [LibraryClasses.common.DXE_CORE]
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 4fce05b1bf3b..f47e21d282e5 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -193,7 +193,7 @@ [LibraryClasses.common.PEI_CORE]
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
   
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
 [LibraryClasses.common.PEIM]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@@ -209,7 +209,7 @@ [LibraryClasses.common.PEIM]
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
   
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
 [LibraryClasses.common.SEC, LibraryClasses.common.PEIM]
   MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf
-- 
1.9.1

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


[edk2] [PATCH 15/23] EmbeddedPkg/AndroidFastboot: drop bogus gArmGlobalVariableGuid dependency

2015-11-26 Thread Ard Biesheuvel
This application lists gArmGlobalVariableGuid as a dependency, but
does not actually need it. So remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf   | 3 ---
 EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c | 2 --
 2 files changed, 5 deletions(-)

diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf 
b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
index ca17af846627..3e115171ce01 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
@@ -56,6 +56,3 @@ [Packages]
 [Packages.ARM, Packages.AARCH64]
   ArmPkg/ArmPkg.dec
   ArmPlatformPkg/ArmPlatformPkg.dec
-
-[Guids.ARM, Guids.AARCH64]
-  gArmGlobalVariableGuid
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c 
b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index 3053cf06873e..acedd3e0e3cd 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -21,8 +21,6 @@
 #include 
 #include 
 
-#include 
-
 #define LINUX_LOADER_COMMAND_LINE   L"%s -f %s -c %s"
 
 // This GUID is defined in the INGF file of ArmPkg/Application/LinuxLoader
-- 
1.9.1

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


[edk2] [PATCH 19/23] ArmPlatformPkg/ArmVExpressFastBootDxe: drop bogus gArmGlobalVariableGuid dep

2015-11-26 Thread Ard Biesheuvel
ArmVExpressFastBootDxe does not use gArmGlobalVariableGuid so drop
the declaration from the .inf.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressFastBootDxe/ArmVExpressFastBootDxe.inf 
| 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressFastBootDxe/ArmVExpressFastBootDxe.inf
 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressFastBootDxe/ArmVExpressFastBootDxe.inf
index 468f5a479998..70cf04f4bd66 100644
--- 
a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressFastBootDxe/ArmVExpressFastBootDxe.inf
+++ 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressFastBootDxe/ArmVExpressFastBootDxe.inf
@@ -46,9 +46,6 @@ [Packages]
   ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
   ArmPkg/ArmPkg.dec
 
-[Guids]
-  gArmGlobalVariableGuid
-
 [Pcd]
   gArmVExpressTokenSpaceGuid.PcdAndroidFastbootNvmDevicePath
   gArmPlatformTokenSpaceGuid.PcdFirmwareVendor
-- 
1.9.1

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


[edk2] [PATCH 07/23] ArmPlatformPkg: drop ArmPlatformGlobalVariableLib resolutions

2015-11-26 Thread Ard Biesheuvel
We can remove all mention of ArmPlatformGlobalVariableLib now that
there are no remaining [transitive] dependencies on it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc | 5 +
 ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc| 3 ---
 ArmPlatformPkg/ArmPlatformPkg.dsc | 9 +
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc| 1 -
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc | 6 +-
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc | 6 +-
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc | 4 
 7 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc 
b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
index f5af4267fee6..e2f9e32fa76c 100644
--- a/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
+++ b/ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc
@@ -188,10 +188,7 @@ [Components.common]
   #
   # PEI Phase modules
   #
-  ArmPlatformPkg/PrePi/PeiMPCore.inf {
-
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
-  }
+  ArmPlatformPkg/PrePi/PeiMPCore.inf
 
   #
   # DXE
diff --git a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc 
b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
index dc21286e2b27..45d7427b780e 100644
--- a/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc
@@ -129,8 +129,6 @@ [LibraryClasses.AARCH64]
   ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf
 
 [LibraryClasses.common.SEC]
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
-
   
ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
   
DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
@@ -164,7 +162,6 @@ [LibraryClasses.common.DXE_DRIVER]
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
 
 [LibraryClasses.common.UEFI_APPLICATION]
   
UefiDecompressLib|IntelFrameworkModulePkg/Library/BaseUefiTianoCustomDecompressLib/BaseUefiTianoCustomDecompressLib.inf
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc 
b/ArmPlatformPkg/ArmPlatformPkg.dsc
index 79004547bc56..bacd10f3cf5f 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dsc
+++ b/ArmPlatformPkg/ArmPlatformPkg.dsc
@@ -134,7 +134,6 @@ [LibraryClasses.common.SEC]
   
ArmTrustedMonitorLib|ArmPlatformPkg/Library/ArmTrustedMonitorLibNull/ArmTrustedMonitorLibNull.inf
 
   
ArmPlatformSecExtraActionLib|ArmPlatformPkg/Library/DebugSecExtraActionLib/DebugSecExtraActionLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
 
   
DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
   
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf
@@ -162,7 +161,6 @@ [LibraryClasses.common.PEI_CORE]
   
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
   
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
 [LibraryClasses.common.PEIM]
@@ -178,7 +176,6 @@ [LibraryClasses.common.PEIM]
   
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
   
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
 
@@ -198,7 +195,6 @@ [LibraryClasses.common.DXE_DRIVER]
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatfo

[edk2] [PATCH 00/23] ArmPkg|ArmPlatformPkg|ArmVirtPkg: remove ArmGlobalVariableLib

2015-11-26 Thread Ard Biesheuvel
As pointed out by Eugene, the use of the ArmPlatformGlobalVariableLib to store
the PEI services pointer violates the PI spec, since it prevents PEI modules
built from a different code base from running under our firmware.

So instead, use the thread ID CPU registers, both for the PEI services table
pointer (as the PI spec mandates), but also for the HOB list pointer that is
recorded in the ArmGlobalVariable region when running under PrePi.

After this change, no users of ArmPlatformGlobalVariableLib remain, so we can
remove all implementations, and all plubming in the early init code in the
various PrePi and PrePeiCore modules that allocate the global variable region.

Ard Biesheuvel (23):
  ArmPlatformPkg/PrePiHobListPointerLib: use thread ID register
  ArmPkg: remove ArmPlatformGlobalVariableLib resolution from ArmPkg.dsc
  BeagleBoardPkg: remove ArmPlatformGlobalVariableLib resolution
  ArmVirtPkg/ArmVirtQemu: move to ArmPkg version of
PeiServicesTablePointerLib
  ArmVirtPkg: drop ArmPlatformGlobalVariableLib dependency
  ArmPlatformPkg: move to ArmPkg version of PeiServicesTablePointerLib
  ArmPlatformPkg: drop ArmPlatformGlobalVariableLib resolutions
  ArmPlatformPkg: remove PeiServicesTablePointerLib implementation
  ArmPlatformPkg: remove all ArmPlatformGlobalVariableLib
implementations
  ArmVirtPkg/PrePi: remove global variable allocation from lowlevel init
  ArmPlatformPkg/PrePi: remove global variable allocation from lowlevel
init
  ArmPlatformPkg/PlatformPeim: remove ArmGlobalVariable lowlevel init
  ArmPlatformPkg/PrePeiCore: remove global variable allocation from
lowlevel init
  ArmPlatformPkg/Sec: remove global variable allocation from lowlevel
init
  EmbeddedPkg/AndroidFastboot: drop bogus gArmGlobalVariableGuid
dependency
  ArmPkg/BdsLib: drop bogus gArmGlobalVariableGuid dependency
  ArmPlatformPkg/Bds: drop bogus ArmGlobalVariable dependencies
  ArmPlatformPkg/ArmJunoDxe: drop bogus gArmGlobalVariableGuid
dependency
  ArmPlatformPkg/ArmVExpressFastBootDxe: drop bogus
gArmGlobalVariableGuid dep
  ArmPlatformPkg/EblCmdLib: drop bogus ArmGlobalVariableHob.h include
  ArmPlatformPkg/PlatformIntelBdsLib: drop bogus gArmGlobalVariableGuid
dep
  ArmPlatformPkg: remove ArmGlobalVariable PCD, GUID and PPI definitions
  ArmPkg: remove SetPrimaryStack and InitializePrimaryStack macros

 ArmPkg/ArmPkg.dsc  
 |   3 -
 ArmPkg/Include/AsmMacroIoLib.h 
 |  36 ---
 ArmPkg/Include/AsmMacroIoLib.inc   
 |  38 ---
 ArmPkg/Include/AsmMacroIoLibV8.h   
 |  35 ---
 ArmPkg/Library/BdsLib/BdsLib.inf   
 |   1 -
 ArmPlatformPkg/ArmJunoPkg/ArmJuno.dsc  
 |   5 +-
 ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
 |   1 -
 ArmPlatformPkg/ArmPlatformPkg-2ndstage.dsc 
 |   3 -
 ArmPlatformPkg/ArmPlatformPkg.dec  
 |  18 
 ArmPlatformPkg/ArmPlatformPkg.dsc  
 |  13 +--
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-CTA15-A7.dsc 
 |   1 -
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc  
 |   6 +-
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-A15_MPCore.dsc  
 |   6 +-
 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc  
 |   8 +-
 
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressFastBootDxe/ArmVExpressFastBootDxe.inf 
|   3 -
 ArmPlatformPkg/Bds/Bds.inf 
 |   1 -
 ArmPlatformPkg/Bds/BootMenu.c  
 |   2 -
 ArmPlatformPkg/Bds/BootOption.c
 |   1 -
 ArmPlatformPkg/Include/Guid/ArmGlobalVariableHob.h 
 |  51 --
 ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h  
 |  38 ---
 ArmPlatformPkg/Include/Ppi/ArmGlobalVariable.h 
 |  55 --
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
   |  76 --
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
 |  44 
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.c
   |  84 

[edk2] [PATCH 11/23] ArmPlatformPkg/PrePi: remove global variable allocation from lowlevel init

2015-11-26 Thread Ard Biesheuvel
Now that we dropped all ArmPlatformGlobalVariableLib dependencies,
there is no longer a need to allocate and clear out the global
variable region in the PrePi init code. So remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S |  7 -
 ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S |  6 
 ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm   |  7 -
 ArmPlatformPkg/PrePi/MainMPCore.c   |  3 +-
 ArmPlatformPkg/PrePi/MainUniCore.c  |  3 +-
 ArmPlatformPkg/PrePi/PeiMPCore.inf  |  3 --
 ArmPlatformPkg/PrePi/PeiUniCore.inf |  3 --
 ArmPlatformPkg/PrePi/PrePi.c| 31 ++--
 ArmPlatformPkg/PrePi/PrePi.h|  2 --
 9 files changed, 4 insertions(+), 61 deletions(-)

diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S 
b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
index 0d0e3e17c170..f63fd44067fc 100644
--- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -133,16 +133,10 @@ _GetStackBase:
   cmp   x0, #1
   bne   _PrepareArguments
 
-_ReserveGlobalVariable:
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x0)
-  // InitializePrimaryStack($GlobalVariableSize, $Tmp1, $Tmp2)
-  InitializePrimaryStack(x0, x1, x2)
-
 _PrepareArguments:
   mov   x0, x10
   mov   x1, x11
   mov   x2, x12
-  mov   x3, sp
 
   // Move sec startup address into a data register
   // Ensure we're jumping to FV version of the code (not boot remapped alias)
@@ -152,7 +146,6 @@ _PrepareArguments:
   //x0 = MpId
   //x1 = UefiMemoryBase
   //x2 = StacksBase
-  //x3 = GlobalVariableBase
   blr   x4
 
 _NeverReturn:
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S 
b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
index f64934480ff4..1311efc5cb2c 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -141,11 +141,6 @@ _GetStackBase:
   cmp   r0, #1
   bne   _PrepareArguments
 
-_ReserveGlobalVariable:
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r0)
-  // InitializePrimaryStack($GlobalVariableSize, $Tmp1)
-  InitializePrimaryStack(r0, r1)
-
 _PrepareArguments:
   mov   r0, r8
   mov   r1, r9
@@ -160,7 +155,6 @@ _PrepareArguments:
   //r0 = MpId
   //r1 = UefiMemoryBase
   //r2 = StacksBase
-  //r3 = GlobalVariableBase
   blx   r4
 
 _NeverReturn:
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm 
b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
index f73c56850d99..a20e3fde0bda 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
@@ -143,16 +143,10 @@ _GetStackBase
   cmp   r0, #1
   bne   _PrepareArguments
 
-_ReserveGlobalVariable
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r0)
-  // InitializePrimaryStack($GlobalVariableSize, $Tmp1)
-  InitializePrimaryStack r0, r1
-
 _PrepareArguments
   mov   r0, r8
   mov   r1, r9
   mov   r2, r10
-  mov   r3, sp
 
   // Move sec startup address into a data register
   // Ensure we're jumping to FV version of the code (not boot remapped alias)
@@ -162,7 +156,6 @@ _PrepareArguments
   //r0 = MpId
   //r1 = UefiMemoryBase
   //r2 = StacksBase
-  //r3 = GlobalVariableBase
   blx   r4
 
 _NeverReturn
diff --git a/ArmPlatformPkg/PrePi/MainMPCore.c 
b/ArmPlatformPkg/PrePi/MainMPCore.c
index bf813730d341..603f4bb8be3f 100644
--- a/ArmPlatformPkg/PrePi/MainMPCore.c
+++ b/ArmPlatformPkg/PrePi/MainMPCore.c
@@ -22,7 +22,6 @@ VOID
 PrimaryMain (
   IN  UINTN UefiMemoryBase,
   IN  UINTN StacksBase,
-  IN  UINTN GlobalVariableBase,
   IN  UINT64StartTimeStamp
   )
 {
@@ -35,7 +34,7 @@ PrimaryMain (
 ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), 
ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
   }
 
-  PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);
+  PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
 
   // We must never return
   ASSERT(FALSE);
diff --git a/ArmPlatformPkg/PrePi/MainUniCore.c 
b/ArmPlatformPkg/PrePi/MainUniCore.c
index 43588a50ddb5..49b02338ebc2 100644
--- a/ArmPlatformPkg/PrePi/MainUniCore.c
+++ b/ArmPlatformPkg/PrePi/MainUniCore.c
@@ -18,7 +18,6 @@ VOID
 PrimaryMain (
   IN  UINTN UefiMemoryBase,
   IN  UINTN StacksBase,
-  IN  UINTN GlobalVariableBase,
   IN  UINT64StartTimeStamp
   )
 {
@@ -27,7 +26,7 @@ PrimaryMain (
 ASSERT(ArmIsMpCore() == 0);
   DEBUG_CODE_END();
 
-  PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);
+  PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
 
   // We must never return
   ASSERT(FALSE);
diff --git a/ArmPlatformPkg/PrePi/PeiMPCo

[edk2] [PATCH 04/23] ArmVirtPkg/ArmVirtQemu: move to ArmPkg version of PeiServicesTablePointerLib

2015-11-26 Thread Ard Biesheuvel
As pointed out by Eugene, the ArmPlatformPkg implementation of
PeiServicesTablePointerLib violates the PI sec, since it uses
ArmPlatformGlobalVariableLib to store the PEI services table pointer
rather than the thread ID cpu registers as the spec requires.

So instead, move to the ArmPkg version of this library, which does
adhere to the PI spec.

Reported-by: Eugene Cohen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 8626919f3a2c..b3066d298009 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -156,7 +156,7 @@ [LibraryClasses.common.SEC]
   
SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
 
 [LibraryClasses.common.PEI_CORE]
@@ -173,7 +173,7 @@ [LibraryClasses.common.PEI_CORE]
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
   
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   
SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
 
 [LibraryClasses.common.PEIM]
@@ -191,7 +191,7 @@ [LibraryClasses.common.PEIM]
   
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
 
   
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
-  
PeiServicesTablePointerLib|ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+  
PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
   
SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
 
 [LibraryClasses.common.DXE_CORE]
-- 
1.9.1

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


[edk2] [PATCH 01/23] ArmPlatformPkg/PrePiHobListPointerLib: use thread ID register

2015-11-26 Thread Ard Biesheuvel
This updates the PrePiHobListPointerLib implementation in ArmPlatformPkg
to move away from ArmPlatformGlobalVariableLib and instead use the thread
ID CPU registers (TPIDRURW and TPIDR_EL0 for v7 and v8, respectively)
for storing the HobList pointer.

Since PrePiHobListPointerLib is specific to PrePi (where PEI core is skipped)
we can share these registers with the PEI services table pointer. By the
same reasoning, the PEI services table pointer and the HobList pointer
already shared the same offset in the ArmPlatformGlobalVariable array.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmPlatformPkg.dec|  3 
++-
 ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c  | 12 
+++-
 ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf |  7 
++-
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec 
b/ArmPlatformPkg/ArmPlatformPkg.dec
index 45aeaeee75f9..cb95516881c7 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -87,7 +87,8 @@ [PcdsFixedAtBuild.common]
   # PeiServicePtr and HobListPtr shares the same location in the PEI Global 
Variable list
   # PeiServicePtr is only valid with PEI Core and HobListPtr only when the PEI 
Core is skipped.
   gArmPlatformTokenSpaceGuid.PcdPeiServicePtrGlobalOffset|0x0|UINT32|0x0017
-  gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset|0x0|UINT32|0x0018
+  ## TO BE REMOVED
+  ## gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset|0x0|UINT32|0x0018
 
   # Size to reserve in the primary core stack for SEC Global Variables
   gArmPlatformTokenSpaceGuid.PcdSecGlobalVariableSize|0x0|UINT32|0x0031
diff --git 
a/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c 
b/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
index 8932e1004970..23e366db2fab 100755
--- a/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
+++ b/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
@@ -13,10 +13,9 @@
 **/
 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 
 /**
   Returns the pointer to the HOB list.
@@ -32,11 +31,7 @@ PrePeiGetHobList (
   VOID
   )
 {
-  VOID* HobList;
-
-  ArmPlatformGetGlobalVariable (PcdGet32 (PcdHobListPtrGlobalOffset), 
sizeof(VOID*), &HobList);
-
-  return HobList;
+  return (VOID *)ArmReadTpidrurw();
 }
 
 
@@ -53,8 +48,7 @@ PrePeiSetHobList (
   IN  VOID  *HobList
   )
 {
-  ArmPlatformSetGlobalVariable (PcdGet32 (PcdHobListPtrGlobalOffset), 
sizeof(VOID*), &HobList);
+  ArmWriteTpidrurw((UINTN)HobList);
 
   return EFI_SUCCESS;
 }
-
diff --git 
a/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf 
b/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
index 16b201e8f6f0..0b98f6ffda8b 100755
--- a/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
+++ b/ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
@@ -25,11 +25,8 @@ [Sources]
 
 [Packages]
   MdePkg/MdePkg.dec
-  ArmPlatformPkg/ArmPlatformPkg.dec
+  ArmPkg/ArmPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
 
 [LibraryClasses]
-  ArmPlatformGlobalVariableLib
-
-[FixedPcd.common]
-  gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset
+  ArmLib
-- 
1.9.1

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


[edk2] [PATCH 08/23] ArmPlatformPkg: remove PeiServicesTablePointerLib implementation

2015-11-26 Thread Ard Biesheuvel
This removes the PeiServicesTablePointerLib implementation under
ArmPlatformPkg that violates the PI spec, and hence should not be
used. Instead, the implementation that resides under ArmPkg should
be used.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/ArmPlatformPkg.dec  
  |  3 +-
 ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
  | 91 
 
ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 | 44 --
 3 files changed, 2 insertions(+), 136 deletions(-)

diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec 
b/ArmPlatformPkg/ArmPlatformPkg.dec
index cb95516881c7..8147db982727 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -86,7 +86,8 @@ [PcdsFixedAtBuild.common]
   gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize|0x4|UINT32|0x0016
   # PeiServicePtr and HobListPtr shares the same location in the PEI Global 
Variable list
   # PeiServicePtr is only valid with PEI Core and HobListPtr only when the PEI 
Core is skipped.
-  gArmPlatformTokenSpaceGuid.PcdPeiServicePtrGlobalOffset|0x0|UINT32|0x0017
+  ## TO BE REMOVED
+  ## 
ArmPlatformTokenSpaceGuid.PcdPeiServicePtrGlobalOffset|0x0|UINT32|0x0017
   ## TO BE REMOVED
   ## gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset|0x0|UINT32|0x0018
 
diff --git 
a/ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c 
b/ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
deleted file mode 100644
index 5c241fa59e3d..
--- 
a/ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
-  PEI Services Table Pointer Library.
-
-  This library is used for PEIM which does executed from flash device directly 
but
-  executed in memory.
-
-  Copyright (c) 2006 - 2010, 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.
-
-**/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/**
-  Caches a pointer PEI Services Table.
-
-  Caches the pointer to the PEI Services Table specified by 
PeiServicesTablePointer
-  in a platform specific manner.
-
-  If PeiServicesTablePointer is NULL, then ASSERT().
-
-  @paramPeiServicesTablePointer   The address of PeiServices pointer.
-**/
-VOID
-EFIAPI
-SetPeiServicesTablePointer (
-  IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
-  )
-{
-  ASSERT (PeiServicesTablePointer != NULL);
-
-  ArmPlatformSetGlobalVariable (PcdGet32 (PcdPeiServicePtrGlobalOffset), 
sizeof(EFI_PEI_SERVICES **), &PeiServicesTablePointer);
-}
-
-/**
-  Retrieves the cached value of the PEI Services Table pointer.
-
-  Returns the cached value of the PEI Services Table pointer in a CPU specific 
manner
-  as specified in the CPU binding section of the Platform Initialization 
Pre-EFI
-  Initialization Core Interface Specification.
-
-  If the cached PEI Services Table pointer is NULL, then ASSERT().
-
-  @return  The pointer to PeiServices.
-
-**/
-CONST EFI_PEI_SERVICES**
-EFIAPI
-GetPeiServicesTablePointer (
-  VOID
-  )
-{
-  EFI_PEI_SERVICES **PeiServicesTablePointer;
-
-  ArmPlatformGetGlobalVariable (PcdGet32 (PcdPeiServicePtrGlobalOffset), 
sizeof(EFI_PEI_SERVICES **), &PeiServicesTablePointer);
-
-  return (CONST EFI_PEI_SERVICES**)PeiServicesTablePointer;
-}
-
-/**
-  Perform CPU specific actions required to migrate the PEI Services Table
-  pointer from temporary RAM to permanent RAM.
-
-  For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
-  immediately preceding the Interrupt Descriptor Table (IDT) in memory.
-  For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
-  immediately preceding the Interrupt Descriptor Table (IDT) in memory.
-  For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
-  a dedicated CPU register.  This means that there is no memory storage
-  associated with storing the PEI Services Table pointer, so no additional
-  migration actions are required for Itanium or ARM CPUs.
-
-**/
-VOID
-EFIAPI
-MigratePeiServicesTablePointer (
-  VOID
-  )
-{
-  return;
-}
diff --git 
a/ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
 
b/ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
deleted file mode 100644
index 307cec844318..
--- 
a/ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
+++ /dev/null
@@ -1,44 +0,0 

[edk2] [PATCH 03/23] BeagleBoardPkg: remove ArmPlatformGlobalVariableLib resolution

2015-11-26 Thread Ard Biesheuvel
Remove the ArmPlatformGlobalVariableLib library class resolution now
that BeagleBoardPkg no longer has a transitive dependency on it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 BeagleBoardPkg/BeagleBoardPkg.dsc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BeagleBoardPkg/BeagleBoardPkg.dsc 
b/BeagleBoardPkg/BeagleBoardPkg.dsc
index 533849228aad..18b031029945 100644
--- a/BeagleBoardPkg/BeagleBoardPkg.dsc
+++ b/BeagleBoardPkg/BeagleBoardPkg.dsc
@@ -132,7 +132,6 @@ [LibraryClasses.common]
 
 [LibraryClasses.common.SEC]
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
 
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
   
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
@@ -178,7 +177,6 @@ [LibraryClasses.common.DXE_DRIVER]
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
-  
ArmPlatformGlobalVariableLib|ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
 
 [LibraryClasses.common.UEFI_APPLICATION]
   
ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf
-- 
1.9.1

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


[edk2] [PATCH 10/23] ArmVirtPkg/PrePi: remove global variable allocation from lowlevel init

2015-11-26 Thread Ard Biesheuvel
Now that we dropped all ArmPlatformGlobalVariableLib dependencies,
there is no longer a need to allocate and clear out the global
variable region in the PrePi init code. So remove it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S |  7 -
 ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf |  3 --
 ArmVirtPkg/PrePi/PrePi.c| 33 ++--
 ArmVirtPkg/PrePi/PrePi.h|  1 -
 4 files changed, 2 insertions(+), 42 deletions(-)

diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S 
b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
index f0cf865b3c93..68049d5df2bf 100644
--- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
+++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
@@ -158,16 +158,10 @@ _GetStackBase:
   cmp   x0, #1
   bne   _PrepareArguments
 
-_ReserveGlobalVariable:
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x0)
-  // InitializePrimaryStack($GlobalVariableSize, $Tmp1, $Tmp2)
-  InitializePrimaryStack(x0, x1, x2)
-
 _PrepareArguments:
   mov   x0, x10
   mov   x1, x11
   mov   x2, x12
-  mov   x3, sp
 
   // Move sec startup address into a data register
   // Ensure we're jumping to FV version of the code (not boot remapped alias)
@@ -177,7 +171,6 @@ _PrepareArguments:
   //x0 = MpId
   //x1 = UefiMemoryBase
   //x2 = StacksBase
-  //x3 = GlobalVariableBase
   blr   x4
 
 _NeverReturn:
diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf 
b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index 8a7a67c1b5d3..966f0185bbda 100755
--- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -61,7 +61,6 @@ [Ppis]
   gArmMpCoreInfoPpiGuid
 
 [Guids]
-  gArmGlobalVariableGuid
   gArmMpCoreInfoGuid
 
 [FeaturePcd]
@@ -79,8 +78,6 @@ [FixedPcd]
   gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
   gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize
 
-  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize
-
   gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
 
   gArmPlatformTokenSpaceGuid.PcdCoreCount
diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index fe7612cec74b..c69cff249e80 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -25,14 +25,10 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "PrePi.h"
 #include "LzmaDecompress.h"
 
-// Not used when PrePi in run in XIP mode
-UINTN mGlobalVariableBase = 0;
-
 EFI_STATUS
 EFIAPI
 ExtractGuidedSectionLibConstructor (
@@ -45,23 +41,6 @@ LzmaDecompressLibConstructor (
   VOID
   );
 
-VOID
-EFIAPI
-BuildGlobalVariableHob (
-  IN EFI_PHYSICAL_ADDRESS GlobalVariableBase,
-  IN UINT32   GlobalVariableSize
-  )
-{
-  ARM_HOB_GLOBAL_VARIABLE  *Hob;
-
-  Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof 
(ARM_HOB_GLOBAL_VARIABLE));
-  ASSERT(Hob != NULL);
-
-  CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);
-  Hob->GlobalVariableBase = GlobalVariableBase;
-  Hob->GlobalVariableSize = GlobalVariableSize;
-}
-
 EFI_STATUS
 GetPlatformPpi (
   IN  EFI_GUID  *PpiGuid,
@@ -90,7 +69,6 @@ VOID
 PrePiMain (
   IN  UINTN UefiMemoryBase,
   IN  UINTN StacksBase,
-  IN  UINTN GlobalVariableBase,
   IN  UINT64StartTimeStamp
   )
 {
@@ -133,9 +111,6 @@ PrePiMain (
   StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
   BuildStackHob (StacksBase, StacksSize);
 
-  // Declare the Global Variable HOB
-  BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 
(PcdPeiGlobalVariableSize));
-
   //TODO: Call CpuPei as a library
   BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
 
@@ -174,8 +149,7 @@ VOID
 CEntryPoint (
   IN  UINTN MpId,
   IN  UINTN UefiMemoryBase,
-  IN  UINTN StacksBase,
-  IN  UINTN GlobalVariableBase
+  IN  UINTN StacksBase
   )
 {
   UINT64   StartTimeStamp;
@@ -199,10 +173,7 @@ CEntryPoint (
   // Enable Instruction Caches on all cores.
   ArmEnableInstructionCache ();
 
-  // Define the Global Variable region
-  mGlobalVariableBase = GlobalVariableBase;
-
-  PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);
+  PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
 
   // DXE Core should always load and never return
   ASSERT (FALSE);
diff --git a/ArmVirtPkg/PrePi/PrePi.h b/ArmVirtPkg/PrePi/PrePi.h
index 15b91e49c9bd..9b828377adc3 100644
--- a/ArmVirtPkg/PrePi/PrePi.h
+++ b/ArmVirtPkg/PrePi/PrePi.h
@@ -41,7 +41,6 @@ VOID
 PrePiMain (
   IN  UINTN UefiMemoryBase,
   IN  UINTN StacksBase,
-  IN  UINTN GlobalVariableBase,
   IN  UINT64StartTimeStamp
   );
 
-- 
1.9.1

__

[edk2] [PATCH 09/23] ArmPlatformPkg: remove all ArmPlatformGlobalVariableLib implementations

2015-11-26 Thread Ard Biesheuvel
This removes the SEC, PEI and DXE variants of ArmPlatformGlobalVariableLib,
which is no longer used, and should not be used since it violates the PI
spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel 
---
 ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h  
 |  38 ---
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
   |  76 --
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
 |  44 
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.c
   |  84 ---
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.inf
 |  40 
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c
   | 107 
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
 |  44 
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.c
   |  81 ---
 
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.inf
 |  39 ---
 9 files changed, 553 deletions(-)

diff --git a/ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h 
b/ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h
deleted file mode 100644
index b1a080c00aa2..
--- a/ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/** @file
-*
-*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.
-*
-*  This program and the accompanying materials
-*  are licensed and made available under the terms and conditions of the BSD 
License
-*  which accompanies this distribution.  The full text of the license may be 
found at
-*  http://opensource.org/licenses/bsd-license.php
-*
-*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
-*
-**/
-
-#ifndef __ARM_PLATFORM_GLOBAL_VARIABLE_LIB_H_
-#define __ARM_PLATFORM_GLOBAL_VARIABLE_LIB_H_
-
-VOID
-ArmPlatformGetGlobalVariable (
-  IN  UINTN VariableOffset,
-  IN  UINTN VariableSize,
-  OUT VOID* Variable
-  );
-
-VOID
-ArmPlatformSetGlobalVariable (
-  IN  UINTN VariableOffset,
-  IN  UINTN VariableSize,
-  OUT VOID* Variable
-  );
-
-VOID*
-ArmPlatformGetGlobalVariableAddress (
-  IN  UINTN VariableOffset
-  );
-
-#endif
-
diff --git 
a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
 
b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
deleted file mode 100644
index 511d0f69de60..
--- 
a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/** @file
-*
-*  Copyright (c) 2011-2012, ARM Limited. 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.
-*
-**/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-UINTN  mGlobalVariableBase = 0;
-
-RETURN_STATUS
-EFIAPI
-ArmPlatformGlobalVariableConstructor (
-  VOID
-  )
-{
-  ARM_HOB_GLOBAL_VARIABLE  *Hob;
-
-  Hob = GetFirstGuidHob (&gArmGlobalVariableGuid);
-  ASSERT (Hob != NULL);
-
-  mGlobalVariableBase = Hob->GlobalVariableBase;
-
-  return EFI_SUCCESS;
-}
-
-VOID
-ArmPlatformGetGlobalVariable (
-  IN  UINTN VariableOffset,
-  IN  UINTN VariableSize,
-  OUT VOID* Variable
-  )
-{
-  if (mGlobalVariableBase == 0) {
-ArmPlatformGlobalVariableConstructor ();
-  }
-
-  CopyMem (Variable, (VOID*)(mGlobalVariableBase + VariableOffset), 
VariableSize);
-}
-
-VOID
-ArmPlatformSetGlobalVariable (
-  IN  UINTN VariableOffset,
-  IN  UINTN VariableSize,
-  OUT VOID* Variable
-  )
-{
-  if (mGlobalVariableBase == 0) {
-ArmPlatformGlobalVariableConstructor ();
-  }
-
-  CopyMem ((VOID*)(mGlobalVariableBase + VariableOffset), Variable, 
VariableSize);
-}
-
-VOID*
-ArmPlatformGetGlobalVariableAddress (
-  IN  UINTN VariableOffset
-  )
-{
-  return (VOID*)(mGlobalVariableBase + VariableOffset);
-}
diff --git 
a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
 
b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
deleted file mode 100644
index e90d6a5811c3..
--- 
a/ArmPlatformPkg/Library/ArmPlatformGlo

Re: [edk2] [patch] NetworkPkg: Fix a bug in HttpBootDriverBindingStop() when destroying child.

2015-11-26 Thread Subramanian, Sriram (System FW, HP Servers)
Looks good. 
Reviewed-by: Sriram Subramanian 

Thanks,
Sriram.

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Zhang 
Lubo
Sent: Thursday, November 26, 2015 12:02 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [patch] NetworkPkg: Fix a bug in HttpBootDriverBindingStop() 
when destroying child.

If Http Driver is being unloaded or DisconnectController() without invoke 
HttpBootStart(),
this will cause an unexpected ASSERT.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Sriram Subramanian 
Reviewed-by: Fu Siyuan 
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
index a7fc8a8..9fb33bb 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
@@ -48,11 +48,10 @@ HttpBootDestroyIp4Children (
   IN HTTP_BOOT_PRIVATE_DATA   *Private
   )
 {
   ASSERT (This != NULL);
   ASSERT (Private != NULL);
-  ASSERT (Private->UsingIpv6 == FALSE);
 
   if (Private->Dhcp4Child != NULL) {
 gBS->CloseProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
@@ -109,11 +108,10 @@ HttpBootDestroyIp6Children (
   IN HTTP_BOOT_PRIVATE_DATA   *Private
   )
 {
   ASSERT (This != NULL);
   ASSERT (Private != NULL);
-  ASSERT (Private->UsingIpv6 == TRUE);
   
   if (Private->Ip6Child != NULL) {
 gBS->CloseProtocol (
Private->Ip6Child,
&gEfiIp6ProtocolGuid,
-- 
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


[edk2] [patch] UefiCpuPkg/PiSmmCpu: Move IDT to page aligned memory.

2015-11-26 Thread jiewen yao
The IDT in ASM is removed. We rely on C code to allocate IDT.
We also move InitializeIDTSmmStackGuard() from ASM to C file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Yao, Jiewen" 
Cc: "Fan, Jeff" 
Cc: "Kinney, Michael D" 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S   | 224 +
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.asm |  34 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c   |  24 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c  |  13 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.S| 249 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.asm  |  33 +---
 UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c|  21 ++
 7 files changed, 72 insertions(+), 526 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S 
b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S
index 4130bf5..eb41410 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.S
@@ -24,6 +24,7 @@ ASM_GLOBAL  ASM_PFX(PageFaultStubFunction)
 ASM_GLOBAL  ASM_PFX(gSmiMtrrs)
 ASM_GLOBAL  ASM_PFX(gcSmiIdtr)
 ASM_GLOBAL  ASM_PFX(gcSmiGdtr)
+ASM_GLOBAL  ASM_PFX(gTaskGateDescriptor)
 ASM_GLOBAL  ASM_PFX(gcPsd)
 ASM_GLOBAL  ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable))
 
@@ -236,207 +237,10 @@ ASM_PFX(gcPsd):
 ASM_PFX(gcSmiGdtr):  .word  GDT_SIZE - 1
  .long  NullSeg
 
-ASM_PFX(gcSmiIdtr):  .word  IDT_SIZE - 1
- .long  _SmiIDT
-
-_SmiIDT:
-# The following segment repeats 32 times:
-# No. 1
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 2
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 3
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 4
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 5
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 6
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 7
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 8
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 9
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 10
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 11
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 12
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 13
-.word 0 # Offset 0:15
-.word  CODE_SEL
-.byte 0 # Unused
-.byte 0x8e  # Interrupt Gate, Present
-.word 0 # Offset 16:31
-# No. 14
-.word 0  

[edk2] [PATCH v2] MdeModulePkg:Replace unsafe string function with safe one.

2015-11-26 Thread Dandan Bi
V2:
Update the Copyright info.
Use StrCpyS instead of StrCatS when copy str1 to str.

Cc: Liming Gao 
Cc: Eric Dong 
Cc: Qiu Shumin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
---
 .../Library/FileExplorerLib/FileExplorer.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c 
b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
index 4e25efc..96d13e7 100644
--- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
+++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
@@ -1,9 +1,9 @@
 /** @file
   File explorer related functions.
 
-  Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
   This software and associated documentation (if any) is furnished
   under a license and may only be used or copied in accordance
   with the terms of the license. Except as permitted by such
   license, no part of this software or documentation may be
   reproduced, stored in a retrieval system, or transmitted in any
@@ -606,29 +606,31 @@ LibAppendFileName (
   IN  CHAR16  *Str2
   )
 {
   UINTN   Size1;
   UINTN   Size2;
+  UINTN   MaxLen;
   CHAR16  *Str;
   CHAR16  *TmpStr;
   CHAR16  *Ptr;
   CHAR16  *LastSlash;
 
   Size1 = StrSize (Str1);
   Size2 = StrSize (Str2);
+  MaxLen = (Size1 + Size2 + sizeof (CHAR16))/ sizeof (CHAR16);
   Str   = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
   ASSERT (Str != NULL);
 
   TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16)); 
   ASSERT (TmpStr != NULL);
 
-  StrCat (Str, Str1);
+  StrCpyS (Str, MaxLen, Str1);
   if (!((*Str == '\\') && (*(Str + 1) == 0))) {
-StrCat (Str, L"\\");
+StrCatS (Str, MaxLen, L"\\");
   }
 
-  StrCat (Str, Str2);
+  StrCatS (Str, MaxLen, Str2);
 
   Ptr   = Str;
   LastSlash = Str;
   while (*Ptr != 0) {
 if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '.' && *(Ptr + 3) 
== L'\\') {
@@ -637,27 +639,27 @@ LibAppendFileName (
   // DO NOT convert the .. if it is at the end of the string. This will
   // break the .. behavior in changing directories.
   //
 
   //
-  // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of 
two strings 
+  // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of 
two strings 
   // that overlap.
   //
-  StrCpy (TmpStr, Ptr + 3);
-  StrCpy (LastSlash, TmpStr);
+  StrCpyS (TmpStr, MaxLen, Ptr + 3);
+  StrCpyS (LastSlash, MaxLen - (UINTN) (LastSlash - Str), TmpStr);
   Ptr = LastSlash;
 } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {
   //
   // Convert a "\.\" to a "\"
   //
 
   //
-  // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of 
two strings 
+  // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of 
two strings 
   // that overlap.
   //
-  StrCpy (TmpStr, Ptr + 2);
-  StrCpy (Ptr, TmpStr);
+  StrCpyS (TmpStr, MaxLen, Ptr + 2);
+  StrCpyS (Ptr, MaxLen - (UINTN) (Ptr - Str), TmpStr);
   Ptr = LastSlash;
 } else if (*Ptr == '\\') {
   LastSlash = Ptr;
 }
 
-- 
1.9.5.msysgit.1

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


[edk2] [Patch] MdePkg: Add Ipmi2.0 definitions head file.

2015-11-26 Thread Daocheng Bu
Add Ipmi2.0 definitions head file based on Ipmi category:
App, Storage and etc.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daocheng Bu 
CC: Jiewen Yao 
---
 MdePkg/Include/IndustryStandard/Ipmi.h |  26 +
 .../IndustryStandard/IpmiNetFnAppDefinitions.h | 614 +
 .../IndustryStandard/IpmiNetFnBridgeDefinitions.h  | 238 
 .../IndustryStandard/IpmiNetFnChassisDefinitions.h | 294 ++
 .../IpmiNetFnFirmwareDefinitions.h |  26 +
 .../IpmiNetFnGroupExtDefinitions.h |  26 +
 .../IpmiNetFnSensorEventDefinitions.h  |  44 ++
 .../IndustryStandard/IpmiNetFnStorageDefinitions.h | 514 +
 .../IpmiNetFnTransportDefinitions.h| 531 ++
 9 files changed, 2313 insertions(+)
 create mode 100644 MdePkg/Include/IndustryStandard/Ipmi.h
 create mode 100644 MdePkg/Include/IndustryStandard/IpmiNetFnAppDefinitions.h
 create mode 100644 MdePkg/Include/IndustryStandard/IpmiNetFnBridgeDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnChassisDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnFirmwareDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnGroupExtDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnSensorEventDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnStorageDefinitions.h
 create mode 100644 
MdePkg/Include/IndustryStandard/IpmiNetFnTransportDefinitions.h

diff --git a/MdePkg/Include/IndustryStandard/Ipmi.h 
b/MdePkg/Include/IndustryStandard/Ipmi.h
new file mode 100644
index 000..de72bcc
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Ipmi.h
@@ -0,0 +1,26 @@
+/** @file   
+  IPMI 2.0 definitions from the IPMI Specification, revision 2.0
+
+  Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.
+  This program and the accompanying materials  
+  are licensed and made available under the terms and conditions of the BSD 
License 
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php   
 
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED. 
+**/
+
+#ifndef _IPMIDEFINITIONS_H_
+#define _IPMIDEFINITIONS_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#endif
diff --git a/MdePkg/Include/IndustryStandard/IpmiNetFnAppDefinitions.h 
b/MdePkg/Include/IndustryStandard/IpmiNetFnAppDefinitions.h
new file mode 100644
index 000..77582e2
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiNetFnAppDefinitions.h
@@ -0,0 +1,614 @@
+/** @file   
+  IPMI 2.0 definitions from the IPMI Specification, revision 2.0
+
+  Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.
+  This program and the accompanying materials  
+  are licensed and made available under the terms and conditions of the BSD 
License 
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php   
 
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED. 
+**/
+
+#ifndef _IPMINETFNAPPDEFINITIONS_H_
+#define _IPMINETFNAPPDEFINITIONS_H_
+
+#pragma pack(1)
+//
+// Net function definition for App command
+//
+#define IPMI_NETFN_APP  0x06
+
+//
+//  Definitions for Get Device ID command   
+//
+#define IPMI_APP_GET_DEVICE_ID 0x1
+
+//
+//  Constants and Structure definitions for "Get Device ID" command to follow 
here
+//
+typedef struct {
+  UINT8   DeviceId;
+  UINT8   DeviceRevision : 4;
+  UINT8   Reserved : 3;
+  UINT8   DeviceSdr : 1;
+  UINT8   MajorFirmwareRev : 7;
+  UINT8   UpdateMode : 1;
+  UINT8   MinorFirmwareRev;
+  UINT8   SpecificationVersion;
+  UINT8   SensorDeviceSupport : 1;
+  UINT8   SdrRepositorySupport : 1;
+  UINT8   SelDeviceSupport : 1;
+  UINT8   FruInventorySupport : 1;
+  UINT8   IpmbMessageReceiver : 1;
+  UINT8   IpmbMessageGenerator : 1;
+  UINT8   BridgeSupport : 1;
+  UINT8   ChassisSupport : 1;
+  UINT8   ManufacturerId[3];
+  UINT16  ProductId;
+  UINT32  AuxFirmwareRevInfo;
+} IPMI_MSG_GET_DEVICE_ID_RSP;
+
+
+//
+//  Definitions for Cold Reset command  
+//
+#define IPMI_APP_COLD_RESET  0x2
+
+//
+//  Constants and Structure definitions for "Cold Reset" command to follow here
+//
+
+//
+//  Definitions for Warm Reset command  
+//
+#define IPMI_APP_WARM_RESET  0x3
+
+//
+//  Constants and Structure definitions for "Warm Reset" command to follow here
+//
+
+//
+//  Definitions for Ge

[edk2] [patch] NetworkPkg: Fix a bug in HttpBootDriverBindingStop() when destroying child.

2015-11-26 Thread Zhang Lubo
If Http Driver is being unloaded or DisconnectController() without invoke 
HttpBootStart(),
this will cause an unexpected ASSERT.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Sriram Subramanian 
Reviewed-by: Fu Siyuan 
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
index a7fc8a8..9fb33bb 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
@@ -48,11 +48,10 @@ HttpBootDestroyIp4Children (
   IN HTTP_BOOT_PRIVATE_DATA   *Private
   )
 {
   ASSERT (This != NULL);
   ASSERT (Private != NULL);
-  ASSERT (Private->UsingIpv6 == FALSE);
 
   if (Private->Dhcp4Child != NULL) {
 gBS->CloseProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
@@ -109,11 +108,10 @@ HttpBootDestroyIp6Children (
   IN HTTP_BOOT_PRIVATE_DATA   *Private
   )
 {
   ASSERT (This != NULL);
   ASSERT (Private != NULL);
-  ASSERT (Private->UsingIpv6 == TRUE);
   
   if (Private->Ip6Child != NULL) {
 gBS->CloseProtocol (
Private->Ip6Child,
&gEfiIp6ProtocolGuid,
-- 
1.9.5.msysgit.1

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