From 6fe3137fe529c9d8ae146041af6681077914ffa8 Mon Sep 17 00:00:00 2001 From: Zhiguang Liu Date: Mon, 1 Jul 2024 15:56:29 +0800 Subject: [PATCH] UefiCpuPkg: Change RestoreVolatileRegisters second parameter Analysis of the current usage patterns revealed that this parameter should consistently set to TRUE. Specifically, the parameter was found to be False in the following scenarios: 1. During the initial volatile register setup for the first AP wake-up in both the PEI and DXE phases. In these instances, the volatile registers are pre-initialized in MpInitLibInitialize(), and manually setting them to zero does not require altering the DR state. 2. When switching the BSP, the new BSP does not synchronize the DR. This behavior is now adjusted to ensure the DR state is synchronized, aligning with a more logical and expected behavior when transitioning BSP roles. Signed-off-by: Zhiguang Liu --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 7eee646312..c3b1620b14 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -118,7 +118,7 @@ FutureBSPProc ( // SaveVolatileRegisters (&DataInHob->APInfo.VolatileRegisters); AsmExchangeRole (&DataInHob->APInfo, &DataInHob->BSPInfo); - RestoreVolatileRegisters (&DataInHob->APInfo.VolatileRegisters, FALSE); + RestoreVolatileRegisters (&DataInHob->APInfo.VolatileRegisters, TRUE); } /** @@ -769,7 +769,7 @@ ApWakeupFunction ( // to initialize AP in InitConfig path. // NOTE: IDTR.BASE stored in CpuMpData->CpuData[ProcessorNumber].VolatileRegisters points to a different IDT shared by all APs. // - RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, FALSE); + RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, TRUE); InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack); ApStartupSignalBuffer = CpuMpData->CpuData[ProcessorNumber].StartupApSignal; } else { @@ -902,7 +902,7 @@ DxeApEntryPoint ( AsmWriteMsr64 (MSR_IA32_EFER, EferMsr.Uint64); } - RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, FALSE); + RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, TRUE); InterlockedIncrement ((UINT32 *)&CpuMpData->FinishedCount); PlaceAPInMwaitLoopOrRunLoop ( CpuMpData->ApLoopMode, @@ -2607,7 +2607,7 @@ SwitchBSPWorker ( // SaveVolatileRegisters (&CpuMpData->BSPInfo.VolatileRegisters); AsmExchangeRole (&CpuMpData->BSPInfo, &CpuMpData->APInfo); - RestoreVolatileRegisters (&CpuMpData->BSPInfo.VolatileRegisters, FALSE); + RestoreVolatileRegisters (&CpuMpData->BSPInfo.VolatileRegisters, TRUE); // // Set the BSP bit of MSR_IA32_APIC_BASE on new BSP //