public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: devel@edk2.groups.io
Cc: Eric Dong <eric.dong@intel.com>
Subject: [PATCH 1/4] MpInitLib: Allocate code buffer for PEI phase
Date: Sat,  7 May 2022 23:13:10 +0800	[thread overview]
Message-ID: <20220507151313.115-2-ray.ni@intel.com> (raw)
In-Reply-To: <20220507151313.115-1-ray.ni@intel.com>

Today's implementation assumes PEI phase runs at 32bit so
the execution-disable feature is not applicable.
It's not always TRUE.
The patch allocates 32bit&64bit code buffer for PEI phase as well.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c |  2 +-
 UefiCpuPkg/Library/MpInitLib/MpLib.c    |  2 +-
 UefiCpuPkg/Library/MpInitLib/MpLib.h    |  2 +-
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 15 ++++++++++-----
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 60d14a5a0e..78cc3e2b93 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -162,7 +162,7 @@ GetWakeupBuffer (
   @retval 0       Cannot find free memory below 4GB.
 **/
 UINTN
-GetModeTransitionBuffer (
+AllocateCodeBuffer (
   IN UINTN  BufferSize
   )
 {
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 91c7afaeb2..3dc1b9f872 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1058,7 +1058,7 @@ AllocateResetVector (
                                    (CpuMpData->WakeupBuffer +
                                     CpuMpData->AddressMap.RendezvousFunnelSize +
                                     CpuMpData->AddressMap.SwitchToRealSize);
-    CpuMpData->WakeupBufferHigh = GetModeTransitionBuffer (
+    CpuMpData->WakeupBufferHigh = AllocateCodeBuffer (
                                     CpuMpData->AddressMap.RendezvousFunnelSize +
                                     CpuMpData->AddressMap.SwitchToRealSize -
                                     CpuMpData->AddressMap.ModeTransitionOffset
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index f8c52426dd..59ab960897 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -442,7 +442,7 @@ GetWakeupBuffer (
   @retval 0       Cannot find free memory below 4GB.
 **/
 UINTN
-GetModeTransitionBuffer (
+AllocateCodeBuffer (
   IN UINTN  BufferSize
   );
 
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index efce574727..65400b95a2 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -299,14 +299,19 @@ GetWakeupBuffer (
   @retval 0       Cannot find free memory below 4GB.
 **/
 UINTN
-GetModeTransitionBuffer (
+AllocateCodeBuffer (
   IN UINTN  BufferSize
   )
 {
-  //
-  // PEI phase doesn't need to do such transition. So simply return 0.
-  //
-  return 0;
+  EFI_STATUS            Status;
+  EFI_PHYSICAL_ADDRESS  Address;
+
+  Status = PeiServicesAllocatePages (EfiBootServicesCode, EFI_SIZE_TO_PAGES (BufferSize), &Address);
+  if (EFI_ERROR (Status)) {
+    Address = 0;
+  }
+
+  return (UINTN)Address;
 }
 
 /**
-- 
2.32.0.windows.1


  reply	other threads:[~2022-05-07 15:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07 15:13 [PATCH 0/4] Refactor MpInitLib Ni, Ray
2022-05-07 15:13 ` Ni, Ray [this message]
2022-05-07 15:13 ` [PATCH 2/4] MpInitLib: remove unneeded global ASM_PFX Ni, Ray
2022-05-07 15:13 ` [PATCH 3/4] MpInitLib: Put SEV logic in separate file Ni, Ray
2022-05-12 14:13   ` Lendacky, Thomas
2022-05-16  3:51     ` Ni, Ray
2022-05-07 15:13 ` [PATCH 4/4] MpInitLib: Only allocate below 1MB memory for 16bit code Ni, Ray
     [not found] ` <16ECDB685492F55B.14104@groups.io>
2022-05-09 11:54   ` [edk2-devel] [PATCH 3/4] MpInitLib: Put SEV logic in separate file Ni, Ray
2022-05-09 16:35     ` Lendacky, Thomas
2022-05-09 21:39 ` [edk2-devel] [PATCH 0/4] Refactor MpInitLib Lendacky, Thomas
2022-05-09 23:16   ` Ni, Ray
2022-05-10 14:44     ` Lendacky, Thomas
2022-05-10 15:13       ` Lendacky, Thomas
2022-05-12  1:21         ` Ni, Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220507151313.115-2-ray.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox