Revert "UefiCpuPkg/PiSmmCpuDxeSmm: Fix buffer overflow issue."

This reverts commit 123b720eeb.

The commit message for commit 123b720eeb is not correct.

Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
This commit is contained in:
Eric Dong 2020-01-07 08:38:22 +08:00 committed by mergify[bot]
parent cc617b6e14
commit 4bb34b6df1
1 changed files with 8 additions and 8 deletions

View File

@ -137,7 +137,7 @@ ReleaseAllAPs (
{ {
UINTN Index; UINTN Index;
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (IsPresentAp (Index)) { if (IsPresentAp (Index)) {
ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run); ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);
} }
@ -170,7 +170,7 @@ AllCpusInSmmWithExceptions (
CpuData = mSmmMpSyncData->CpuData; CpuData = mSmmMpSyncData->CpuData;
ProcessorInfo = gSmmCpuPrivate->ProcessorInfo; ProcessorInfo = gSmmCpuPrivate->ProcessorInfo;
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) { if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) {
if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmDelayed) != 0) { if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) != 0) && SmmCpuFeaturesGetSmmRegister (Index, SmmRegSmmDelayed) != 0) {
continue; continue;
@ -305,7 +305,7 @@ SmmWaitForApArrival (
// //
// Send SMI IPIs to bring outside processors in // Send SMI IPIs to bring outside processors in
// //
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) { if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId != INVALID_APIC_ID) {
SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId); SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId);
} }
@ -361,7 +361,7 @@ WaitForAllAPsNotBusy (
{ {
UINTN Index; UINTN Index;
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
// //
// Ignore BSP and APs which not call in SMM. // Ignore BSP and APs which not call in SMM.
// //
@ -608,7 +608,7 @@ BSPHandler (
// //
while (TRUE) { while (TRUE) {
PresentCount = 0; PresentCount = 0;
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (*(mSmmMpSyncData->CpuData[Index].Present)) { if (*(mSmmMpSyncData->CpuData[Index].Present)) {
PresentCount ++; PresentCount ++;
} }
@ -1343,7 +1343,7 @@ InternalSmmStartupAllAPs (
} }
CpuCount = 0; CpuCount = 0;
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (IsPresentAp (Index)) { if (IsPresentAp (Index)) {
CpuCount ++; CpuCount ++;
@ -1375,13 +1375,13 @@ InternalSmmStartupAllAPs (
// Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail for not // Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail for not
// block mode. // block mode.
// //
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (IsPresentAp (Index)) { if (IsPresentAp (Index)) {
AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy); AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy);
} }
} }
for (Index = 0; Index < mMaxNumberOfCpus; Index++) { for (Index = mMaxNumberOfCpus; Index-- > 0;) {
if (IsPresentAp (Index)) { if (IsPresentAp (Index)) {
mSmmMpSyncData->CpuData[Index].Procedure = (EFI_AP_PROCEDURE2) Procedure; mSmmMpSyncData->CpuData[Index].Procedure = (EFI_AP_PROCEDURE2) Procedure;
mSmmMpSyncData->CpuData[Index].Parameter = ProcedureArguments; mSmmMpSyncData->CpuData[Index].Parameter = ProcedureArguments;