mirror of https://review.coreboot.org/STM.git
Stm/StmPkg/Core/Runtime - Add execution processor number to shared header
This patch adds the VM/PE execution processor number to the STM shared header. It also formalizes the fields of the shared STM header as this is the third element to be added. Before, the header definition was informal where each element was identified as an offset. This patch also cleans up some of the code related to the header in PeSmiHandler.c by removing duplicative code. Signed-off-by: Eugene Myers <edmyers@tycho.nsa.gov>
This commit is contained in:
parent
408349065f
commit
e1538fd996
|
@ -214,10 +214,11 @@ void LaunchPeVm(UINT32 PeType, UINT32 CpuIndex)
|
|||
mGuestContextCommonSmm[PeType].GuestContextPerCpu[0].Register.Rdx));
|
||||
|
||||
PeVmData[PeType].UserModule.RunCount++;
|
||||
// set the runcount into the STM shared page
|
||||
|
||||
*((UINT64 *)(PeVmData[PeType].SharedPageStm + sizeof(UINT64))) =
|
||||
PeVmData[PeType].UserModule.RunCount;
|
||||
// set the runcount into the STM shared page
|
||||
SHARED_PAGE_STM_HEADER * SharedPageStmHeader = (SHARED_PAGE_STM_HEADER *) (UINT64*) PeVmData[PeType].SharedPageStm;
|
||||
SharedPageStmHeader->RunCount = PeVmData[PeType].UserModule.RunCount;
|
||||
SharedPageStmHeader->ExecProcessor = CpuIndex;
|
||||
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld LaunchPeVM - Initiating PE/VM run number: %d\n",
|
||||
|
@ -225,10 +226,11 @@ void LaunchPeVm(UINT32 PeType, UINT32 CpuIndex)
|
|||
PeVmData[PeType].UserModule.RunCount));
|
||||
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld LaunchPeVM - SharedPageStm 0x%016llx 0x%016llx\n",
|
||||
"%ld LaunchPeVM - SharedPageStm 0x%016llx 0x%016llx 0x%016llx\n",
|
||||
CpuIndex,
|
||||
*((UINT64 *)(PeVmData[PeType].SharedPageStm)),
|
||||
*((UINT64 *)(PeVmData[PeType].SharedPageStm + sizeof(UINT64)))));
|
||||
SharedPageStmHeader->NumProcessors,
|
||||
SharedPageStmHeader->RunCount,
|
||||
SharedPageStmHeader->ExecProcessor));
|
||||
|
||||
// Make sure we take the correct path upon RSM
|
||||
mHostContextCommon.HostContextPerCpu[CpuIndex].GuestVmType = PeType;
|
||||
|
|
|
@ -37,9 +37,8 @@ static UINT32 retvalue = 0;
|
|||
|
||||
UINT32 PeSmiHandler(UINT32 CpuIndex)
|
||||
{
|
||||
ROOT_VMX_STATE * RootState;
|
||||
UINT64 * NumProcessors;
|
||||
UINT32 PeType = PE_PERM;
|
||||
ROOT_VMX_STATE * RootState = (ROOT_VMX_STATE *) ((char *) PeVmData[PeType].SharedPageStm + sizeof(SHARED_PAGE_STM_HEADER));
|
||||
UINT32 CpuNum;
|
||||
UINT32 TimerSTS = 0;
|
||||
|
||||
|
@ -74,13 +73,6 @@ UINT32 PeSmiHandler(UINT32 CpuIndex)
|
|||
|
||||
// VM/PE sends a SMI to the other processors when it wants state information from other CPU's
|
||||
|
||||
NumProcessors = (UINT64 *) PeVmData[PeType].SharedPageStm;
|
||||
|
||||
//sizeof(*NumProcessors) + sizeof(*NumProcessors));
|
||||
RootState = (ROOT_VMX_STATE *) ((char *)NumProcessors + 64);
|
||||
|
||||
// get the local processor state
|
||||
|
||||
GetRootVmxState(CpuIndex, &RootState[CpuIndex]);
|
||||
|
||||
CpuReadySync(CpuIndex); // wait for everyone to finish
|
||||
|
@ -124,11 +116,6 @@ UINT32 PeSmiHandler(UINT32 CpuIndex)
|
|||
PeSmiControl.PeSmiState));
|
||||
#endif
|
||||
InterlockedCompareExchange32(&PeSmiControl.PeSmiState, PESMIHSMI, PESMIHTMR);
|
||||
|
||||
NumProcessors = (UINT64 *) PeVmData[PeType].SharedPageStm;
|
||||
|
||||
//sizeof(*NumProcessors) + sizeof(*NumProcessors));
|
||||
RootState = (ROOT_VMX_STATE *) ((char *)NumProcessors + 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,11 +124,6 @@ UINT32 PeSmiHandler(UINT32 CpuIndex)
|
|||
|
||||
if(InterlockedCompareExchange32(&PeSmiControl.PeSmiState, PESMIHTMR, PESMIHTMR) == PESMIHTMR)
|
||||
{
|
||||
NumProcessors = (UINT64 *) PeVmData[PeType].SharedPageStm;
|
||||
|
||||
//sizeof(*NumProcessors) + sizeof(*NumProcessors));
|
||||
RootState = (ROOT_VMX_STATE *) ((char *)NumProcessors + 64);
|
||||
|
||||
GetRootVmxState(CpuIndex, &RootState[CpuIndex]);
|
||||
CpuReadySync(CpuIndex);
|
||||
|
||||
|
|
|
@ -371,8 +371,15 @@ typedef struct ROOT_VMX_STATE {
|
|||
#define VMX_STATE_ROOT 1
|
||||
#define VMX_STATE_GUEST 2
|
||||
|
||||
typedef struct SHARED_PAGE_STM_HEADER {
|
||||
UINT64 NumProcessors;
|
||||
UINT64 RunCount;
|
||||
UINT64 ExecProcessor;
|
||||
UINT64 Reserved[5];
|
||||
} SHARED_PAGE_STM_HEADER;
|
||||
|
||||
void GetRootVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState);
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -63,10 +63,9 @@ static UINT64 VMCS_32_CONTROL_2ND_PROCESSOR_BASED_VM_EXECUTION_OFFSET;
|
|||
int GetMultiProcessorState(UINT32 CpuIndex)
|
||||
{
|
||||
UINT32 PeType = PE_PERM;
|
||||
UINT64 * NumProcessors = (UINT64 *) PeVmData[PeType].SharedPageStm;
|
||||
|
||||
// = (ROOT_VMX_STATE *) (NumProcessors + sizeof(*NumProcessors));
|
||||
ROOT_VMX_STATE * RootState;
|
||||
SHARED_PAGE_STM_HEADER * SharedPageStmHeader = (SHARED_PAGE_STM_HEADER *) (UINT64*) PeVmData[PeType].SharedPageStm;
|
||||
ROOT_VMX_STATE * RootState = (ROOT_VMX_STATE *) ((char *) PeVmData[PeType].SharedPageStm + sizeof(SHARED_PAGE_STM_HEADER));
|
||||
UINT32 CpuNum;
|
||||
#if 0
|
||||
DEBUG((EFI_D_INFO,
|
||||
|
@ -82,9 +81,7 @@ int GetMultiProcessorState(UINT32 CpuIndex)
|
|||
}
|
||||
// first clear out the data structures and set the number of processors
|
||||
|
||||
//sizeof(*NumProcessors) + sizeof(*NumProcessors));
|
||||
RootState = (ROOT_VMX_STATE *) ((char *)NumProcessors + 64 );
|
||||
*NumProcessors = mHostContextCommon.CpuNum; // number of CPUs
|
||||
SharedPageStmHeader->NumProcessors = mHostContextCommon.CpuNum; // number of CPUs
|
||||
|
||||
ZeroMem ((VOID *)(UINTN) RootState,
|
||||
sizeof(ROOT_VMX_STATE) * mHostContextCommon.CpuNum);
|
||||
|
|
Loading…
Reference in New Issue