From: Jeff Fan <jeff.fan@intel.com>
To: edk2-devel@lists.01.org
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
Eric Dong <eric.dong@intel.com>
Subject: [PATCH v2 2/2] UefiCpuPkg/MpInitLib: Check APIC mode change around AP function
Date: Wed, 24 May 2017 16:18:41 +0800 [thread overview]
Message-ID: <20170524081841.10496-3-jeff.fan@intel.com> (raw)
In-Reply-To: <20170524081841.10496-1-jeff.fan@intel.com>
If APIC ID values are changed during AP functions execution, we need to update
new APIC ID values in local data structure accordingly.
But if APIC mode change happened during AP function execution, we do not support
APIC ID value changed.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
---
UefiCpuPkg/Library/MpInitLib/MpLib.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 735e099..c6f8191 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -547,6 +547,7 @@ ApWakeupFunction (
volatile UINT32 *ApStartupSignalBuffer;
CPU_INFO_IN_HOB *CpuInfoInHob;
UINT64 ApTopOfStack;
+ UINTN CurrentApicMode;
//
// AP finished assembly code and begin to execute C code
@@ -560,6 +561,7 @@ ApWakeupFunction (
ProgramVirtualWireMode ();
SyncLocalApicTimerSetting (CpuMpData);
+ CurrentApicMode = GetApicMode ();
while (TRUE) {
if (CpuMpData->InitFlag == ApInitConfig) {
//
@@ -627,11 +629,23 @@ ApWakeupFunction (
ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal;
CpuInfoInHob[ProcessorNumber].ApTopOfStack = CpuInfoInHob[CpuMpData->NewBspNumber].ApTopOfStack;
} else {
- //
- // Re-get the CPU APICID and Initial APICID
- //
- CpuInfoInHob[ProcessorNumber].ApicId = GetApicId ();
- CpuInfoInHob[ProcessorNumber].InitialApicId = GetInitialApicId ();
+ if (CpuInfoInHob[ProcessorNumber].ApicId != GetApicId () ||
+ CpuInfoInHob[ProcessorNumber].InitialApicId != GetInitialApicId ()) {
+ if (CurrentApicMode != GetApicMode ()) {
+ //
+ // If APIC mode change happened during AP function execution,
+ // we do not support APIC ID value changed.
+ //
+ ASSERT (FALSE);
+ CpuDeadLoop ();
+ } else {
+ //
+ // Re-get the CPU APICID and Initial APICID if they are changed
+ //
+ CpuInfoInHob[ProcessorNumber].ApicId = GetApicId ();
+ CpuInfoInHob[ProcessorNumber].InitialApicId = GetInitialApicId ();
+ }
+ }
}
}
SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateFinished);
--
2.9.3.windows.2
prev parent reply other threads:[~2017-05-24 8:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 8:18 [PATCH v2 0/2] Enable X2APIC after MP service is ready Jeff Fan
2017-05-24 8:18 ` [PATCH v2 1/2] UefiCpuPkg/CpuCommonFeaturesLib: Support X2APIC enable Jeff Fan
2017-05-24 8:18 ` Jeff Fan [this message]
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=20170524081841.10496-3-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