From: Jeff Fan <jeff.fan@intel.com>
To: edk2-devel@lists.01.org
Cc: Michael Kinney <michael.d.kinney@intel.com>,
Feng Tian <feng.tian@intel.com>
Subject: [Patch 2/6] UefiCpuPkg/MpInitLib: Move allocating reserved memory for AP loop code
Date: Wed, 24 Aug 2016 22:45:20 +0800 [thread overview]
Message-ID: <1472049924-8228-3-git-send-email-jeff.fan@intel.com> (raw)
In-Reply-To: <1472049924-8228-1-git-send-email-jeff.fan@intel.com>
In Exit Boot Services callback function, we cannot use allocate memory services
because it may change the memory map that has been gotten by OS.
This fix is to move allocating reserved memory for AP loop code to
InitMpGlobalData() and save the memory address in one global variable.
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 42d320f..383eec9 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -23,7 +23,7 @@ CPU_MP_DATA *mCpuMpData = NULL;
EFI_EVENT mCheckAllApsEvent = NULL;
EFI_EVENT mMpInitExitBootServicesEvent = NULL;
volatile BOOLEAN mStopCheckAllApsStatus = TRUE;
-
+VOID *mReservedApLoopFunc = NULL;
/**
Get the pointer to CPU MP Data structure.
@@ -258,19 +258,11 @@ MpInitExitBootServicesCallback (
)
{
CPU_MP_DATA *CpuMpData;
- VOID *ReservedApLoopFunc;
- //
- // Avoid APs access invalid buff data which allocated by BootServices,
- // so we will allocate reserved data for AP loop code.
- //
+
CpuMpData = GetCpuMpData ();
CpuMpData->PmCodeSegment = GetProtectedModeCS ();
CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode);
- ReservedApLoopFunc = AllocateReservedCopyPool (
- CpuMpData->AddressMap.RelocateApLoopFuncSize,
- CpuMpData->AddressMap.RelocateApLoopFuncAddress
- );
- WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, ReservedApLoopFunc);
+ WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, mReservedApLoopFunc);
DEBUG ((DEBUG_INFO, "MpInitExitBootServicesCallback() done!\n"));
}
@@ -288,6 +280,18 @@ InitMpGlobalData (
SaveCpuMpData (CpuMpData);
+ //
+ // Avoid APs access invalid buff data which allocated by BootServices,
+ // so we will allocate reserved data for AP loop code.
+ // Allocating it in advance since memory services are not available in
+ // Exit Boot Services callback function.
+ //
+ mReservedApLoopFunc = AllocateReservedCopyPool (
+ CpuMpData->AddressMap.RelocateApLoopFuncSize,
+ CpuMpData->AddressMap.RelocateApLoopFuncAddress
+ );
+ ASSERT (mReservedApLoopFunc != NULL);
+
Status = gBS->CreateEvent (
EVT_TIMER | EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
--
2.7.4.windows.1
next prev parent reply other threads:[~2016-08-24 14:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 14:45 [Patch 0/6] Fixed bugs in MpInitLib Jeff Fan
2016-08-24 14:45 ` [Patch 1/6] UefiCpuPkg/MpInitLib: Move timeout delay to WakupAp() Jeff Fan
2016-08-24 14:45 ` Jeff Fan [this message]
2016-08-24 14:45 ` [Patch 3/6] UefiCpuPkg/MpInitLib: Rename EndOfPeiFlag to SaveRestoreFlag Jeff Fan
2016-08-24 14:45 ` [Patch 4/6] UefiCpuPkg/MpInitLib: Fix function header comments typo Jeff Fan
2016-08-24 14:45 ` [Patch 5/6] UefiCpuPkg/MpInitLib: Move two functions location Jeff Fan
2016-08-24 14:45 ` [Patch 6/6] UefiCpuPkg/MpInitLib: Don't allocate reset vector in Exit Boot Service Jeff Fan
2016-08-25 5:21 ` [Patch 0/6] Fixed bugs in MpInitLib Tian, Feng
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=1472049924-8228-3-git-send-email-jeff.fan@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