mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg/PiSmmCpuDxeSmm: Allocate buffer for global semaphores
Get semaphores alignment/size requirement and allocate aligned buffer for all global spin lock and semaphores. 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> Reviewed-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
328f84b156
commit
1d64853193
|
@ -21,6 +21,8 @@ UINT64 gSmiMtrrs[MTRR_NUMBER_OF_FIXED_MTRR
|
|||
UINT64 gPhyMask;
|
||||
SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData = NULL;
|
||||
UINTN mSmmMpSyncDataSize;
|
||||
SMM_CPU_SEMAPHORES mSmmCpuSemaphores;
|
||||
UINTN mSemaphoreSize;
|
||||
|
||||
/**
|
||||
Performs an atomic compare exchange operation to get semaphore.
|
||||
|
@ -1193,6 +1195,48 @@ Exit:
|
|||
AsmWriteCr2 (Cr2);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocate buffer for all semaphores and spin locks.
|
||||
|
||||
**/
|
||||
VOID
|
||||
InitializeSmmCpuSemaphores (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN ProcessorCount;
|
||||
UINTN TotalSize;
|
||||
UINTN GlobalSemaphoresSize;
|
||||
UINTN SemaphoreSize;
|
||||
UINTN Pages;
|
||||
UINTN *SemaphoreBlock;
|
||||
UINTN SemaphoreAddr;
|
||||
|
||||
SemaphoreSize = GetSpinLockProperties ();
|
||||
ProcessorCount = gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
|
||||
GlobalSemaphoresSize = (sizeof (SMM_CPU_SEMAPHORE_GLOBAL) / sizeof (VOID *)) * SemaphoreSize;
|
||||
TotalSize = GlobalSemaphoresSize;
|
||||
DEBUG((EFI_D_INFO, "One Semaphore Size = 0x%x\n", SemaphoreSize));
|
||||
DEBUG((EFI_D_INFO, "Total Semaphores Size = 0x%x\n", TotalSize));
|
||||
Pages = EFI_SIZE_TO_PAGES (TotalSize);
|
||||
SemaphoreBlock = AllocatePages (Pages);
|
||||
ASSERT (SemaphoreBlock != NULL);
|
||||
ZeroMem (SemaphoreBlock, TotalSize);
|
||||
|
||||
SemaphoreAddr = (UINTN)SemaphoreBlock;
|
||||
mSmmCpuSemaphores.SemaphoreGlobal.Counter = (UINT32 *)SemaphoreAddr;
|
||||
SemaphoreAddr += SemaphoreSize;
|
||||
mSmmCpuSemaphores.SemaphoreGlobal.InsideSmm = (BOOLEAN *)SemaphoreAddr;
|
||||
SemaphoreAddr += SemaphoreSize;
|
||||
mSmmCpuSemaphores.SemaphoreGlobal.AllCpusInSync = (BOOLEAN *)SemaphoreAddr;
|
||||
SemaphoreAddr += SemaphoreSize;
|
||||
mSmmCpuSemaphores.SemaphoreGlobal.PFLock = (SPIN_LOCK *)SemaphoreAddr;
|
||||
SemaphoreAddr += SemaphoreSize;
|
||||
mSmmCpuSemaphores.SemaphoreGlobal.CodeAccessCheckLock
|
||||
= (SPIN_LOCK *)SemaphoreAddr;
|
||||
|
||||
mSemaphoreSize = SemaphoreSize;
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize un-cacheable data.
|
||||
|
@ -1215,6 +1259,8 @@ InitializeMpSyncData (
|
|||
mSmmMpSyncData->BspIndex = (UINT32)-1;
|
||||
}
|
||||
mSmmMpSyncData->EffectiveSyncMode = (SMM_CPU_SYNC_MODE) PcdGet8 (PcdCpuSmmSyncMode);
|
||||
|
||||
InitializeSmmCpuSemaphores ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -354,6 +354,25 @@ typedef struct {
|
|||
UINT64 MtrrBaseMaskPtr; // Offset 0x58
|
||||
} PROCESSOR_SMM_DESCRIPTOR;
|
||||
|
||||
|
||||
///
|
||||
/// All global semaphores' pointer
|
||||
///
|
||||
typedef struct {
|
||||
volatile UINT32 *Counter;
|
||||
volatile BOOLEAN *InsideSmm;
|
||||
volatile BOOLEAN *AllCpusInSync;
|
||||
SPIN_LOCK *PFLock;
|
||||
SPIN_LOCK *CodeAccessCheckLock;
|
||||
} SMM_CPU_SEMAPHORE_GLOBAL;
|
||||
|
||||
///
|
||||
/// All semaphores' information
|
||||
///
|
||||
typedef struct {
|
||||
SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal;
|
||||
} SMM_CPU_SEMAPHORES;
|
||||
|
||||
extern IA32_DESCRIPTOR gcSmiGdtr;
|
||||
extern IA32_DESCRIPTOR gcSmiIdtr;
|
||||
extern VOID *gcSmiIdtrPtr;
|
||||
|
|
Loading…
Reference in New Issue