[edk2] [PATCH] ShellPkg SmbiosView: Display Type 0 BIOS segment in hexadecimal

2017-04-21 Thread Jeff Westfahl
The SMBIOS Type 0 BIOS segment field is currently displayed in decimal.
Since this field is likely to have a value like 0xE800 or 0xF000, using
hexadecimal seems like a better choice.

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl 
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 50d15ef..038f111 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -316,7 +316,7 @@ SmbiosPrintStructure (
   case 0:
 PRINT_PENDING_STRING (Struct, Type0, Vendor);
 PRINT_PENDING_STRING (Struct, Type0, BiosVersion);
-PRINT_STRUCT_VALUE (Struct, Type0, BiosSegment);
+PRINT_STRUCT_VALUE_H (Struct, Type0, BiosSegment);
 PRINT_PENDING_STRING (Struct, Type0, BiosReleaseDate);
 ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_BIOS_SIZE), gShellDebug1HiiHandle, 64 * 
(Struct->Type0->BiosSize + 1));
 
-- 
2.7.4

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


[edk2] [PATCH 4/4] MdePkg/dsc: add SmmIoLib

2017-04-21 Thread Jiewen Yao
Cc: Jeff Fan 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 MdePkg/MdePkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 8b69de3..d9c2c32 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -154,6 +154,7 @@
   MdePkg/Library/BaseS3SmbusLib/BaseS3SmbusLib.inf
   MdePkg/Library/BaseS3StallLib/BaseS3StallLib.inf
   MdePkg/Library/SmmMemLib/SmmMemLib.inf
+  MdePkg/Library/SmmIoLib/SmmIoLib.inf
   MdePkg/Library/BaseRngLib/BaseRngLib.inf
   MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf
   MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf
-- 
2.7.4.windows.1

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


[edk2] [PATCH 3/4] MdePkg/dec: Add SmmIoLib.

2017-04-21 Thread Jiewen Yao
Cc: Jeff Fan 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 MdePkg/MdePkg.dec | 4 
 1 file changed, 4 insertions(+)

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3310029..5774417 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -246,6 +246,10 @@
   #
   SmmMemLib|Include/Library/SmmMemLib.h
 
+  ##  @libraryclass  Provides services for Smm IO Operation.
+  #
+  SmmIoLib|Include/Library/SmmIoLib.h
+
   ##  @libraryclass  Provides services to enable/disable periodic SMI handlers.
   #
   SmmPeriodicSmiLib|Include/Library/SmmPeriodicSmiLib.h
-- 
2.7.4.windows.1

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


[edk2] [PATCH 2/4] MdePkg/SmmIoLib: Add sample instance.

2017-04-21 Thread Jiewen Yao
The sample instance check if IO resource is valid
one defined in GCD.
A platform may choose add more check to exclude some
other IO resource.

Cc: Jeff Fan 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 MdePkg/Library/SmmIoLib/SmmIoLib.c   | 331 
 MdePkg/Library/SmmIoLib/SmmIoLib.inf |  53 
 MdePkg/Library/SmmIoLib/SmmIoLib.uni |  23 ++
 3 files changed, 407 insertions(+)

diff --git a/MdePkg/Library/SmmIoLib/SmmIoLib.c 
b/MdePkg/Library/SmmIoLib/SmmIoLib.c
new file mode 100644
index 000..995adac
--- /dev/null
+++ b/MdePkg/Library/SmmIoLib/SmmIoLib.c
@@ -0,0 +1,331 @@
+/** @file
+  Instance of SMM IO check library.
+
+  SMM IO check library library implementation. This library consumes GCD to 
collect all valid
+  IO space defined by a platform.
+  A platform may have its own SmmIoLib instance to exclude more IO space.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+EFI_GCD_MEMORY_SPACE_DESCRIPTOR   *mSmmIoLibGcdMemSpace   = NULL;
+UINTN mSmmIoLibGcdMemNumberOfDesc = 0;
+
+EFI_PHYSICAL_ADDRESS  mSmmIoLibInternalMaximumSupportMemAddress = 0;
+
+VOID  *mSmmIoLibRegistrationEndOfDxe;
+VOID  *mSmmIoLibRegistrationReadyToLock;
+
+BOOLEAN   mSmmIoLibReadyToLock = FALSE;
+
+/**
+  Calculate and save the maximum support address.
+
+**/
+VOID
+SmmIoLibInternalCalculateMaximumSupportAddress (
+  VOID
+  )
+{
+  VOID *Hob;
+  UINT32   RegEax;
+  UINT8MemPhysicalAddressBits;
+
+  //
+  // Get physical address bits supported.
+  //
+  Hob = GetFirstHob (EFI_HOB_TYPE_CPU);
+  if (Hob != NULL) {
+MemPhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;
+  } else {
+AsmCpuid (0x8000, , NULL, NULL, NULL);
+if (RegEax >= 0x8008) {
+  AsmCpuid (0x8008, , NULL, NULL, NULL);
+  MemPhysicalAddressBits = (UINT8) RegEax;
+} else {
+  MemPhysicalAddressBits = 36;
+}
+  }
+  //
+  // IA-32e paging translates 48-bit linear addresses to 52-bit physical 
addresses.
+  //
+  ASSERT (MemPhysicalAddressBits <= 52);
+  if (MemPhysicalAddressBits > 48) {
+MemPhysicalAddressBits = 48;
+  }
+
+  //
+  // Save the maximum support address in one global variable
+  //
+  mSmmIoLibInternalMaximumSupportMemAddress = 
(EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, MemPhysicalAddressBits) - 1);
+  DEBUG ((DEBUG_INFO, "mSmmIoLibInternalMaximumSupportMemAddress = 0x%lx\n", 
mSmmIoLibInternalMaximumSupportMemAddress));
+}
+
+/**
+  This function check if the MMIO resource is valid per processor architecture 
and
+  valid per platform design.
+
+  @param BaseAddress  The MMIO start address to be checked.
+  @param Length   The MMIO length to be checked.
+  @param OwnerA GUID representing the owner of the resource.
+  This GUID may be used by producer to correlate the 
device ownership of the resource.
+  NULL means no specific owner.
+
+  @retval TRUE  This MMIO resource is valid per processor architecture and 
valid per platform design.
+  @retval FALSE This MMIO resource is not valid per processor architecture or 
valid per platform design.
+**/
+BOOLEAN
+EFIAPI
+SmmIsMmioValid (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINT64Length,
+  IN EFI_GUID  *Owner  OPTIONAL
+  )
+{
+  UINTN   Index;
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;
+  BOOLEAN InValidRegion;
+
+  //
+  // Check override.
+  // NOTE: (B:0->L:4G) is invalid for IA32, but (B:1->L:4G-1)/(B:4G-1->L:1) is 
valid.
+  //
+  if ((Length > mSmmIoLibInternalMaximumSupportMemAddress) ||
+  (BaseAddress > mSmmIoLibInternalMaximumSupportMemAddress) ||
+  ((Length != 0) && (BaseAddress > 
(mSmmIoLibInternalMaximumSupportMemAddress - (Length - 1 ) {
+//
+// Overflow happen
+//
+DEBUG ((
+  DEBUG_ERROR,
+  "SmmIsMmioValid: Overflow: BaseAddress (0x%lx) - Length (0x%lx), 
MaximumSupportMemAddress (0x%lx)\n",
+  BaseAddress,
+  Length,
+  mSmmIoLibInternalMaximumSupportMemAddress
+  ));
+return FALSE;
+  }
+
+  //
+  // Check override for valid MMIO region
+  //
+  if (mSmmIoLibReadyToLock) {
+InValidRegion = FALSE;
+for (Index = 0; Index < 

[edk2] [PATCH 1/4] MdePkg/SmmIoLib: Add header file.

2017-04-21 Thread Jiewen Yao
This SmmIoLib is used to check if an IO resource
is valid in SMM.

Cc: Jeff Fan 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao 
---
 MdePkg/Include/Library/SmmIoLib.h | 42 
 1 file changed, 42 insertions(+)

diff --git a/MdePkg/Include/Library/SmmIoLib.h 
b/MdePkg/Include/Library/SmmIoLib.h
new file mode 100644
index 000..7820f1e
--- /dev/null
+++ b/MdePkg/Include/Library/SmmIoLib.h
@@ -0,0 +1,42 @@
+/** @file
+  Provides services for SMM IO Operation.
+
+  The SMM IO Library provides function for checking if IO resource is 
accessible inside of SMM.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _SMM_IO_LIB_H_
+#define _SMM_IO_LIB_H_
+
+/**
+  This function check if the MMIO resource is valid per processor architecture 
and
+  valid per platform design.
+
+  @param BaseAddress  The MMIO start address to be checked.
+  @param Length   The MMIO length to be checked.
+  @param OwnerA GUID representing the owner of the resource.
+  This GUID may be used by producer to correlate the 
device ownership of the resource.
+  NULL means no specific owner.
+
+  @retval TRUE  This MMIO resource is valid per processor architecture and 
valid per platform design.
+  @retval FALSE This MMIO resource is not valid per processor architecture or 
valid per platform design.
+**/
+BOOLEAN
+EFIAPI
+SmmIsMmioValid (
+  IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+  IN UINT64Length,
+  IN EFI_GUID  *Owner  OPTIONAL
+  );
+
+#endif
+
-- 
2.7.4.windows.1

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


[edk2] [PATCH 0/4] Add SmmIoLib

2017-04-21 Thread Jiewen Yao
This patch series add SmmIoLib.
It is the first part of bugzillar 491.
https://bugzilla.tianocore.org/show_bug.cgi?id=491
Move generic function - OpalIsValidMmioSpace from OPAL
driver to library.

This SmmIoLib is similar to SmmMemLib.

The second part of bugzillar 491 is to update consumer
SecurityPkg/Tcg/Opal/OpalPasswordSmm. It will be
handled in future patch series.

Jiewen Yao (4):
  MdePkg/SmmIoLib: Add header file.
  MdePkg/SmmIoLib: Add sample instance.
  MdePkg/dec: Add SmmIoLib.
  MdePkg/dsc: add SmmIoLib

 MdePkg/Include/Library/SmmIoLib.h|  42 +++
 MdePkg/Library/SmmIoLib/SmmIoLib.c   | 331 
 MdePkg/Library/SmmIoLib/SmmIoLib.inf |  53 
 MdePkg/Library/SmmIoLib/SmmIoLib.uni |  23 ++
 MdePkg/MdePkg.dec|   4 +
 MdePkg/MdePkg.dsc|   1 +
 6 files changed, 454 insertions(+)
 create mode 100644 MdePkg/Include/Library/SmmIoLib.h
 create mode 100644 MdePkg/Library/SmmIoLib/SmmIoLib.c
 create mode 100644 MdePkg/Library/SmmIoLib/SmmIoLib.inf
 create mode 100644 MdePkg/Library/SmmIoLib/SmmIoLib.uni

-- 
2.7.4.windows.1

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


Re: [edk2] [PATCH] kvm: pass the virtual SEI syndrome to guest OS

2017-04-21 Thread gengdongjiu
Hi all/Laszlo,

  sorry, I have a question to consult with you.


On 2017/4/7 2:55, Laszlo Ersek wrote:
> On 04/06/17 14:35, gengdongjiu wrote:
>> Dear, Laszlo
>>Thanks for your detailed explanation.
>>
>> On 2017/3/29 19:58, Laszlo Ersek wrote:
>>> (This ought to be one of the longest address lists I've ever seen :)
>>> Thanks for the CC. I'm glad Shannon is already on the CC list. For good
>>> measure, I'm adding MST and Igor.)
>>>
>>> On 03/29/17 12:36, Achin Gupta wrote:
 Hi gengdongjiu,

 On Wed, Mar 29, 2017 at 05:36:37PM +0800, gengdongjiu wrote:
>
> Hi Laszlo/Biesheuvel/Qemu developer,
>
>Now I encounter a issue and want to consult with you in ARM64 
> platform, as described below:
>
> when guest OS happen synchronous or asynchronous abort, kvm needs
> to send the error address to Qemu or UEFI through sigbus to
> dynamically generate APEI table. from my investigation, there are
> two ways:
>
> (1) Qemu get the error address, and generate the APEI table, then
> notify UEFI to know this generation, then inject abort error to
> guest OS, guest OS read the APEI table.
> (2) Qemu get the error address, and let UEFI to generate the APEI
> table, then inject abort error to guest OS, guest OS read the APEI
> table.

 Just being pedantic! I don't think we are talking about creating the APEI 
 table
 dynamically here. The issue is: Once KVM has received an error that is 
 destined
 for a guest it will raise a SIGBUS to Qemu. Now before Qemu can inject the 
 error
 into the guest OS, a CPER (Common Platform Error Record) has to be 
 generated
 corresponding to the error source (GHES corresponding to memory subsystem,
 processor etc) to allow the guest OS to do anything meaningful with the
 error. So who should create the CPER is the question.

 At the EL3/EL2 interface (Secure Firmware and OS/Hypervisor), an error 
 arrives
 at EL3 and secure firmware (at EL3 or a lower secure exception level) is
 responsible for creating the CPER. ARM is experimenting with using a 
 Standalone
 MM EDK2 image in the secure world to do the CPER creation. This will avoid
 adding the same code in ARM TF in EL3 (better for security). The error 
 will then
 be injected into the OS/Hypervisor (through SEA/SEI/SDEI) through ARM 
 Trusted
 Firmware.

 Qemu is essentially fulfilling the role of secure firmware at the EL2/EL1
 interface (as discussed with Christoffer below). So it should generate the 
 CPER
 before injecting the error.

 This is corresponds to (1) above apart from notifying UEFI (I am assuming 
 you
 mean guest UEFI). At this time, the guest OS already knows where to pick 
 up the
 CPER from through the HEST. Qemu has to create the CPER and populate its 
 address
 at the address exported in the HEST. Guest UEFI should not be involved in 
 this
 flow. Its job was to create the HEST at boot and that has been done by this
 stage.

 Qemu folk will be able to add but it looks like support for CPER 
 generation will
 need to be added to Qemu. We need to resolve this.

 Do shout if I am missing anything above.
>>>
>>> After reading this email, the use case looks *very* similar to what
>>> we've just done with VMGENID for QEMU 2.9.
>>>
>>> We have a facility between QEMU and the guest firmware, called "ACPI
>>> linker/loader", with which QEMU instructs the firmware to
>>>
>>> - allocate and download blobs into guest RAM (AcpiNVS type memory) --
>>> ALLOCATE command,
>>>
>>> - relocate pointers in those blobs, to fields in other (or the same)
>>> blobs -- ADD_POINTER command,
>>>
>>> - set ACPI table checksums -- ADD_CHECKSUM command,
>>>
>>> - and send GPAs of fields within such blobs back to QEMU --
>>> WRITE_POINTER command.
>>>
>>> This is how I imagine we can map the facility to the current use case
>>> (note that this is the first time I read about HEST / GHES / CPER):

Laszlo lists a Qemu GHES table generation solution, Mainly use the four 
commands: "ALLOCATE/ADD_POINTER/ADD_CHECKSUM/WRITE_POINTER" to communicate with 
BIOS
so whether the four commands needs to be supported by the guest firware/UEFI.  
I found the  "WRITE_POINTER" always failed. so I suspect guest UEFI/firmware 
not support the "WRITE_POINTER" command. please help me confirm it, thanks so 
much.


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


[edk2] [PATCH 2/2] UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector

2017-04-21 Thread Jeff Fan
Because we will always borrow the AP reset vector space for AP waking up. We
needn't allocate such range to prevent other module to use it. It could simply
the code.

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

Cc: Feng Tian 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan 
---
 UefiCpuPkg/Library/MpInitLib/MpLib.h  | 22 +--
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |  6 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c   | 93 ---
 3 files changed, 2 insertions(+), 119 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index 7a272d7..989b3f8 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -1,7 +1,7 @@
 /** @file
   Common header file for MP Initialize Library.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -542,26 +542,6 @@ IsMwaitSupport (
   );
 
 /**
-  Notify function on End Of PEI PPI.
-
-  On S3 boot, this function will restore wakeup buffer data.
-  On normal boot, this function will flag wakeup buffer to be un-used type.
-
-  @param[in]  PeiServicesThe pointer to the PEI Services Table.
-  @param[in]  NotifyDescriptor   Address of the notification descriptor data 
structure.
-  @param[in]  PpiAddress of the PPI that was installed.
-
-  @retval EFI_SUCCESSWhen everything is OK.
-**/
-EFI_STATUS
-EFIAPI
-CpuMpEndOfPeiCallback (
-  IN EFI_PEI_SERVICES **PeiServices,
-  IN EFI_PEI_NOTIFY_DESCRIPTOR*NotifyDescriptor,
-  IN VOID *Ppi
-  );
-
-/**
   Get available system memory below 1MB by specified size.
 
   @param[in]  CpuMpData  The pointer to CPU MP Data structure.
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf 
b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
index 0c6873d..fa84e39 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  MP Initialize Library instance for PEI driver.
 #
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.
+#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
@@ -50,15 +50,11 @@
   LocalApicLib
   MemoryAllocationLib
   HobLib
-  PeiServicesLib
   MtrrLib
   CpuLib
   UefiCpuLib
   SynchronizationLib
 
-[Ppis]
-  gEfiEndOfPeiSignalPpiGuid ## NOTIFY
-
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber## CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds  ## CONSUMES
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index 5ce5788..9ee5aca 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -13,18 +13,6 @@
 **/
 
 #include "MpLib.h"
-#include 
-#include 
-
-//
-// Global PEI notify function descriptor on EndofPei event
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mMpInitLibNotifyList = 
{
-  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
-  ,
-  CpuMpEndOfPeiCallback
-};
-
 
 /**
   Enable Debug Agent to support source debugging on AP function.
@@ -77,64 +65,6 @@ SaveCpuMpData (
 }
 
 /**
-  Notify function on End Of PEI PPI.
-
-  On S3 boot, this function will restore wakeup buffer data.
-  On normal boot, this function will flag wakeup buffer to be un-used type.
-
-  @param[in]  PeiServicesThe pointer to the PEI Services Table.
-  @param[in]  NotifyDescriptor   Address of the notification descriptor data 
structure.
-  @param[in]  PpiAddress of the PPI that was installed.
-
-  @retval EFI_SUCCESSWhen everything is OK.
-**/
-EFI_STATUS
-EFIAPI
-CpuMpEndOfPeiCallback (
-  IN EFI_PEI_SERVICES **PeiServices,
-  IN EFI_PEI_NOTIFY_DESCRIPTOR*NotifyDescriptor,
-  IN VOID *Ppi
-  )
-{
-  EFI_STATUSStatus;
-  EFI_BOOT_MODE BootMode;
-  CPU_MP_DATA   *CpuMpData;
-  EFI_PEI_HOB_POINTERS  Hob;
-  EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
-
-  DEBUG ((DEBUG_INFO, "PeiMpInitLib: CpuMpEndOfPeiCallback () invoked\n"));
-
-  Status = PeiServicesGetBootMode ();
-  ASSERT_EFI_ERROR (Status);
-
-  CpuMpData = GetCpuMpData ();
-  if (BootMode != BOOT_ON_S3_RESUME) {
-//
-// 

[edk2] [PATCH 0/2] Borrow the space below 1MB for AP reset vector

2017-04-21 Thread Jeff Fan
Current, CpuMpPei will find the available memory space below 1MB for AP reset
vector. And CpuMpPei will build resource HOB on this range to prevent other
PEI modules to use this range.

However, on some FSP usage model, this range maybe used by the code out of FSP.
CpuMpPei may change the original memory contents and cause other code crash.

We could update CpuMpPei not to change the original contents of this range
around AP waking up. Thus, it will not impact the other code on FSP usage model.

This updating is tiny and less impact on performance.

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

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

Jeff Fan (2):
  UefiCpuPkg/MpInitLib: save/restore original contents
  UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector

 UefiCpuPkg/Library/MpInitLib/MpLib.h  |  22 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf |   6 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c   | 107 +-
 3 files changed, 5 insertions(+), 130 deletions(-)

-- 
2.9.3.windows.2

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


[edk2] [PATCH 1/2] UefiCpuPkg/MpInitLib: save/restore original contents

2017-04-21 Thread Jeff Fan
If APs is in HLT-LOOP mode, we need AP reset vector for waking up APs. This
updating is to save/restore original contents of AP reset vector around waking
up APs always.

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

Cc: Feng Tian 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan 
---
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index fb1d48f..5ce5788 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -1,7 +1,7 @@
 /** @file
   MP initialize support functions for PEI phase.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -129,10 +129,8 @@ CpuMpEndOfPeiCallback (
   }
   Hob.Raw = GET_NEXT_HOB (Hob);
 }
-  } else {
-CpuMpData->SaveRestoreFlag = TRUE;
-RestoreWakeupBuffer (CpuMpData);
   }
+
   return EFI_SUCCESS;
 }
 
@@ -286,12 +284,8 @@ AllocateResetVector (
 CpuMpData->WakeupBuffer  = GetWakeupBuffer (ApResetVectorSize);
 CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)
 (CpuMpData->WakeupBuffer + 
CpuMpData->AddressMap.RendezvousFunnelSize);
-BackupAndPrepareWakeupBuffer (CpuMpData);
-  }
-
-  if (CpuMpData->SaveRestoreFlag) {
-BackupAndPrepareWakeupBuffer (CpuMpData);
   }
+  BackupAndPrepareWakeupBuffer (CpuMpData);
 }
 
 /**
@@ -304,9 +298,7 @@ FreeResetVector (
   IN CPU_MP_DATA  *CpuMpData
   )
 {
-  if (CpuMpData->SaveRestoreFlag) {
-RestoreWakeupBuffer (CpuMpData);
-  }
+  RestoreWakeupBuffer (CpuMpData);
 }
 
 /**
-- 
2.9.3.windows.2

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