public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Borrow the space below 1MB for AP reset vector
@ 2017-04-21  6:04 Jeff Fan
  2017-04-21  6:04 ` [PATCH 1/2] UefiCpuPkg/MpInitLib: save/restore original contents Jeff Fan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jeff Fan @ 2017-04-21  6:04 UTC (permalink / raw)
  To: edk2-devel; +Cc: Feng Tian, Michael Kinney

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 <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] UefiCpuPkg/MpInitLib: save/restore original contents
  2017-04-21  6:04 [PATCH 0/2] Borrow the space below 1MB for AP reset vector Jeff Fan
@ 2017-04-21  6:04 ` Jeff Fan
  2017-04-21  6:04 ` [PATCH 2/2] UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector Jeff Fan
  2017-04-25  2:36 ` [PATCH 0/2] Borrow the space below 1MB for " Tian, Feng
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Fan @ 2017-04-21  6:04 UTC (permalink / raw)
  To: edk2-devel; +Cc: Feng Tian, Michael Kinney

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 <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
 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.<BR>
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
   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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector
  2017-04-21  6:04 [PATCH 0/2] Borrow the space below 1MB for AP reset vector Jeff Fan
  2017-04-21  6:04 ` [PATCH 1/2] UefiCpuPkg/MpInitLib: save/restore original contents Jeff Fan
@ 2017-04-21  6:04 ` Jeff Fan
  2017-04-25  2:36 ` [PATCH 0/2] Borrow the space below 1MB for " Tian, Feng
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Fan @ 2017-04-21  6:04 UTC (permalink / raw)
  To: edk2-devel; +Cc: Feng Tian, Michael Kinney

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 <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
 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.<BR>
+  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
   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]  PeiServices        The pointer to the PEI Services Table.
-  @param[in]  NotifyDescriptor   Address of the notification descriptor data structure.
-  @param[in]  Ppi                Address of the PPI that was installed.
-
-  @retval EFI_SUCCESS        When 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.<BR>
+#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
 #  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 <Ppi/EndOfPeiPhase.h>
-#include <Library/PeiServicesLib.h>
-
-//
-// 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),
-  &gEfiEndOfPeiSignalPpiGuid,
-  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]  PeiServices        The pointer to the PEI Services Table.
-  @param[in]  NotifyDescriptor   Address of the notification descriptor data structure.
-  @param[in]  Ppi                Address of the PPI that was installed.
-
-  @retval EFI_SUCCESS        When everything is OK.
-**/
-EFI_STATUS
-EFIAPI
-CpuMpEndOfPeiCallback (
-  IN EFI_PEI_SERVICES             **PeiServices,
-  IN EFI_PEI_NOTIFY_DESCRIPTOR    *NotifyDescriptor,
-  IN VOID                         *Ppi
-  )
-{
-  EFI_STATUS                Status;
-  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 (&BootMode);
-  ASSERT_EFI_ERROR (Status);
-
-  CpuMpData = GetCpuMpData ();
-  if (BootMode != BOOT_ON_S3_RESUME) {
-    //
-    // Get the HOB list for processing
-    //
-    Hob.Raw = GetHobList ();
-    //
-    // Collect memory ranges
-    //
-    while (!END_OF_HOB_LIST (Hob)) {
-      if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
-        MemoryHob = Hob.MemoryAllocation;
-        if (MemoryHob->AllocDescriptor.MemoryBaseAddress == CpuMpData->WakeupBuffer) {
-          //
-          // Flag this HOB type to un-used
-          //
-          GET_HOB_TYPE (Hob) = EFI_HOB_TYPE_UNUSED;
-          break;
-        }
-      }
-      Hob.Raw = GET_NEXT_HOB (Hob);
-    }
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
   Check if AP wakeup buffer is overlapped with existing allocated buffer.
 
   @param[in]  WakeupBufferStart     AP wakeup buffer start address.
@@ -244,14 +174,6 @@ GetWakeupBuffer (
           }
           DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",
                                WakeupBufferStart, WakeupBufferSize));
-          //
-          // Create a memory allocation HOB.
-          //
-          BuildMemoryAllocationHob (
-            WakeupBufferStart,
-            WakeupBufferSize,
-            EfiBootServicesData
-            );
           return WakeupBufferStart;
         }
       }
@@ -322,22 +244,7 @@ InitMpGlobalData (
   IN CPU_MP_DATA               *CpuMpData
   )
 {
-  EFI_STATUS      Status;
-
   SaveCpuMpData (CpuMpData);
-
-  if (CpuMpData->CpuCount == 1) {
-    //
-    // If only BSP exists, return
-    //
-    return;
-  }
-
-  //
-  // Register an event for EndOfPei
-  //
-  Status  = PeiServicesNotifyPpi (&mMpInitLibNotifyList);
-  ASSERT_EFI_ERROR (Status);
 }
 
 /**
-- 
2.9.3.windows.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Borrow the space below 1MB for AP reset vector
  2017-04-21  6:04 [PATCH 0/2] Borrow the space below 1MB for AP reset vector Jeff Fan
  2017-04-21  6:04 ` [PATCH 1/2] UefiCpuPkg/MpInitLib: save/restore original contents Jeff Fan
  2017-04-21  6:04 ` [PATCH 2/2] UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector Jeff Fan
@ 2017-04-25  2:36 ` Tian, Feng
  2 siblings, 0 replies; 4+ messages in thread
From: Tian, Feng @ 2017-04-25  2:36 UTC (permalink / raw)
  To: Fan, Jeff, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Tian, Feng

Reviewed-by: Feng Tian <feng.tian@Intel.com>

Thanks
Feng

-----Original Message-----
From: Fan, Jeff 
Sent: Friday, April 21, 2017 2:04 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.tian@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [PATCH 0/2] Borrow the space below 1MB for AP reset vector

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 <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-25  2:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-21  6:04 [PATCH 0/2] Borrow the space below 1MB for AP reset vector Jeff Fan
2017-04-21  6:04 ` [PATCH 1/2] UefiCpuPkg/MpInitLib: save/restore original contents Jeff Fan
2017-04-21  6:04 ` [PATCH 2/2] UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector Jeff Fan
2017-04-25  2:36 ` [PATCH 0/2] Borrow the space below 1MB for " Tian, Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox