mirror of https://review.coreboot.org/STM.git
General code cleanup - PeVmxState.c
This commit is contained in:
parent
218beee77d
commit
801195c81b
|
@ -56,7 +56,9 @@ int GetMultiProcessorState(UINT32 CpuIndex)
|
|||
{
|
||||
UINT32 PeType = PE_PERM;
|
||||
UINT64 * NumProcessors = (UINT64 *) PeVmData[PeType].SharedPageStm;
|
||||
ROOT_VMX_STATE * RootState; // = (ROOT_VMX_STATE *) (NumProcessors + sizeof(*NumProcessors));
|
||||
|
||||
// = (ROOT_VMX_STATE *) (NumProcessors + sizeof(*NumProcessors));
|
||||
ROOT_VMX_STATE * RootState;
|
||||
UINT32 CpuNum;
|
||||
|
||||
DEBUG((EFI_D_INFO,
|
||||
|
@ -72,10 +74,12 @@ int GetMultiProcessorState(UINT32 CpuIndex)
|
|||
}
|
||||
// first clear out the data structures and set the number of processors
|
||||
|
||||
RootState = (ROOT_VMX_STATE *) ((char *)NumProcessors + 64 );//sizeof(*NumProcessors) + sizeof(*NumProcessors));
|
||||
//sizeof(*NumProcessors) + sizeof(*NumProcessors));
|
||||
RootState = (ROOT_VMX_STATE *) ((char *)NumProcessors + 64 );
|
||||
*NumProcessors = mHostContextCommon.CpuNum; // number of CPUs
|
||||
|
||||
ZeroMem ((VOID *)(UINTN) RootState, sizeof(ROOT_VMX_STATE) * mHostContextCommon.CpuNum);
|
||||
ZeroMem ((VOID *)(UINTN) RootState,
|
||||
sizeof(ROOT_VMX_STATE) * mHostContextCommon.CpuNum);
|
||||
|
||||
// make sure that the VMCS offsets are setup
|
||||
|
||||
|
@ -83,9 +87,11 @@ int GetMultiProcessorState(UINT32 CpuIndex)
|
|||
|
||||
// send an SMI to the other processors
|
||||
|
||||
if(InterlockedCompareExchange32(&PeSmiControl.PeSmiState, PESMINULL, PESMIPSMI) != PESMINULL) //&PeSmiControl.PeSmiState = 1;
|
||||
if(InterlockedCompareExchange32(&PeSmiControl.PeSmiState,
|
||||
PESMINULL,
|
||||
PESMIPSMI) != PESMINULL)
|
||||
{
|
||||
DEBUG((EFI_D_INFO,
|
||||
DEBUG((EFI_D_ERROR,
|
||||
"%ld x - Aborting, SMI handler already there. PeSmiState %ld\n",
|
||||
CpuIndex,
|
||||
PeSmiControl.PeSmiState));
|
||||
|
@ -99,14 +105,10 @@ int GetMultiProcessorState(UINT32 CpuIndex)
|
|||
|
||||
// get the local processor state
|
||||
|
||||
//CpuReadySync(CpuIndex);
|
||||
GetRootVmxState(CpuIndex, &RootState[CpuIndex]);
|
||||
|
||||
// need to think about this --- without it this hangs, what in context of other processors
|
||||
//InterlockedCompareExchange32(&PeSmiControl.PeSmiState, PESMIPSMI, PESMINULL);//PeSmiControl.PeSmiState = 0; // all done - may need to sync processors in the case of
|
||||
// another SMI coming in
|
||||
|
||||
CpuReadySync(CpuIndex); // wait for everyone to finish the job - PeSmiHandler will set PeSmiState to 0
|
||||
CpuReadySync(CpuIndex); // wait for everyone to finish the job
|
||||
//- PeSmiHandler will set PeSmiState to 0
|
||||
// once everyone has synched up
|
||||
|
||||
for(CpuNum = 0; CpuNum < mHostContextCommon.CpuNum; CpuNum++)
|
||||
|
@ -114,7 +116,6 @@ int GetMultiProcessorState(UINT32 CpuIndex)
|
|||
PrintVmxState(CpuNum, &RootState[CpuNum]);
|
||||
}
|
||||
|
||||
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld GetMultiProcessorState - Completed. PeSmiState: %ld\n",
|
||||
CpuIndex,
|
||||
|
@ -150,14 +151,17 @@ void GetRootVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState)
|
|||
RootState->Vmxon = mHostContextCommon.HostContextPerCpu[CpuIndex].Vmxon;
|
||||
//UINT32 ApicId = (UINT32) (get_apic_id() & 0xFF);
|
||||
RootState->LinkVMCS = VmRead64(VMCS_64_GUEST_VMCS_LINK_PTR_INDEX);
|
||||
RootState->ExecutiveVMCS = VmRead64(VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_INDEX); // get the executive VMCS
|
||||
|
||||
// DEBUG((EFI_D_ERROR, "%ld GetRootVmxState\n VMXON: 0x%016llx\n ExecutiveVMCS: 0x%016llx\n LinkVMCS: 0x%016llx\n",
|
||||
// CpuIndex,
|
||||
// RootState->Vmxon,
|
||||
// RootState->ExecutiveVMCS,
|
||||
// RootState->LinkVMCS));
|
||||
|
||||
// get the executive VMCS
|
||||
RootState->ExecutiveVMCS = VmRead64(VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_INDEX);
|
||||
|
||||
#if 0
|
||||
DEBUG((EFI_D_ERROR, "%ld GetRootVmxState\n VMXON: 0x%016llx\n ExecutiveVMCS: 0x%016llx\n LinkVMCS: 0x%016llx\n",
|
||||
CpuIndex,
|
||||
RootState->Vmxon,
|
||||
RootState->ExecutiveVMCS,
|
||||
RootState->LinkVMCS));
|
||||
#endif
|
||||
RootState->RootGuestCR0 = VmReadN(VMCS_N_GUEST_CR0_INDEX);
|
||||
RootState->RootGuestCR3 = VmReadN(VMCS_N_GUEST_CR3_INDEX);
|
||||
RootState->RootGuestCR4 = VmReadN(VMCS_N_GUEST_CR4_INDEX);
|
||||
|
@ -178,41 +182,36 @@ void GetRootVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState)
|
|||
|
||||
if(RootState->ExecutiveVMCS == RootState->Vmxon) // ref: section 34.15.4.7
|
||||
{
|
||||
// we are in root operation, so our VMCS of interest is in the VNCS-Link field
|
||||
// we are in root operation, so our VMCS of interest
|
||||
// is in the VNCS-Link field
|
||||
|
||||
if(RootState->LinkVMCS != 0xFFFFFFFFFFFFFFFF)
|
||||
{
|
||||
RootState->VmcsType = 1; // guest-VM being sericed by VMM
|
||||
HostRootVMCS = RootState->LinkVMCS;
|
||||
//HostRootVMCS = VmRead64(VMCS_64_GUEST_VMCS_LINK_PTR_INDEX);
|
||||
RootState->VmxState = VMX_STATE_ROOT;
|
||||
//DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d): execVMCS is vmxon: 0x%016llx using VMCS_LINK_POINTER\n",
|
||||
//CpuIndex, RootState->VmcsType, HostRootVMCS));
|
||||
}
|
||||
else
|
||||
{
|
||||
HostRootVMCS = RootState->ExecutiveVMCS;
|
||||
RootState->VmcsType = 2;
|
||||
//HostRootVMCS = VmRead64(VMCS_64_GUEST_VMCS_LINK_PTR_INDEX);
|
||||
RootState->VmxState = VMX_STATE_ROOT;
|
||||
//DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d): execVMCS is vmxon: But LinkVMCS is 0xFFFFFFFFFFFFFFF so no current Vmcs. Using Executive Vmcs: %llx\n",
|
||||
// CpuIndex, RootState->VmcsType, HostRootVMCS));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// in guest operation, so our VMCS of interest is in the executive-VMCS field
|
||||
// in guest operation, so our VMCS of interest
|
||||
// is in the executive-VMCS field
|
||||
|
||||
RootState->VmcsType = 3;
|
||||
HostRootVMCS = RootState->ExecutiveVMCS;
|
||||
RootState->VmxState = VMX_STATE_GUEST;
|
||||
//DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d): execVMCS is guest VMCS: 0x%016llx using Executive VMCS\n",
|
||||
//CpuIndex, RootState->VmcsType, HostRootVMCS));
|
||||
}
|
||||
|
||||
AsmVmClear(&(CurrentVMCSSave));
|
||||
AsmVmPtrStore(&CurrentVMCSSave);
|
||||
RootGuestRIP_M = *(UINT64 *)((UINTN)CurrentVMCSSave + (UINTN)VMCS_N_GUEST_RIP_OFFSET);
|
||||
RootGuestRIP_M = *(UINT64 *)((UINTN)CurrentVMCSSave +
|
||||
(UINTN)VMCS_N_GUEST_RIP_OFFSET);
|
||||
|
||||
VmcsFlushStart:
|
||||
FlushCount = 0;
|
||||
|
@ -222,8 +221,12 @@ VmcsFlushStart:
|
|||
{
|
||||
// got here because the in-memory copy of the VMCS is different than
|
||||
// what is in the processor - so we need to flush
|
||||
//DEBUG((EFI_D_DEBUG, "%ld - GetRootState: RootGuestRIPMemory: 0x%016llx, Location: 0x%016llx\n",
|
||||
//CpuIndex, RootGuestRIPMemory, ((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_RIP_OFFSET)));
|
||||
#if 0
|
||||
DEBUG((EFI_D_INFO, "%ld - GetRootState: RootGuestRIPMemory: 0x%016llx, Location: 0x%016llx\n",
|
||||
CpuIndex,
|
||||
RootGuestRIPMemory,
|
||||
((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_RIP_OFFSET)));
|
||||
#endif
|
||||
// first create a dummy VMCS
|
||||
VmxRevId = AsmReadMsr32(IA32_VMX_BASIC_MSR_INDEX);
|
||||
DummyVmcs[FlushCount] = (char *) AllocatePages(VmcsSizeInPages);
|
||||
|
@ -232,7 +235,7 @@ VmcsFlushStart:
|
|||
{
|
||||
// ran out of memory - release everything and start over
|
||||
// that way someone else hopefully gets a chance to complete
|
||||
DEBUG((EFI_D_INFO,
|
||||
DEBUG((EFI_D_ERROR,
|
||||
"%ld - GetRootState: ran out of memory - so free everything and restart - Flushcount: %d\n",
|
||||
CpuIndex,
|
||||
FlushCount));
|
||||
|
@ -248,11 +251,13 @@ VmcsFlushStart:
|
|||
|
||||
memcpy(DummyVmcs[FlushCount], &VmxRevId, 4);
|
||||
AsmVmPtrLoad((UINT64 *) &DummyVmcs[FlushCount]);
|
||||
RootGuestRIP_M = *(UINT64 *)((UINTN)CurrentVMCSSave + (UINTN)VMCS_N_GUEST_RIP_OFFSET); // try again
|
||||
RootGuestRIP_M = *(UINT64 *)((UINTN)CurrentVMCSSave +
|
||||
(UINTN)VMCS_N_GUEST_RIP_OFFSET); // try again
|
||||
FlushCount++;
|
||||
}
|
||||
|
||||
AsmVmPtrLoad(&CurrentVMCSSave); // in any case, reload this and free the dummies if necessary
|
||||
// in any case, reload this and free the dummies if necessary
|
||||
AsmVmPtrLoad(&CurrentVMCSSave);
|
||||
|
||||
if(FlushCount > 0)
|
||||
{
|
||||
|
@ -260,7 +265,6 @@ VmcsFlushStart:
|
|||
"%ld GetRootVmxState - Flush necessary to get VMCS in sync. Flushcount=%d\n",
|
||||
CpuIndex,
|
||||
FlushCount));
|
||||
//DEBUG((EFI_D_INFO, "%ld GetRootVmxState: after Flush: VMCS_N_GUEST_RIP_MEMORY: 0x%016llx (test) \n", CpuIndex, RootGuestRIPMemory));
|
||||
// release the buffers
|
||||
for(i = 0; i < FlushCount; i++)
|
||||
{
|
||||
|
@ -273,24 +277,35 @@ VmcsFlushStart:
|
|||
//AsmVmPtrLoad(&HostRootVMCS);
|
||||
|
||||
RootState->HostRootVMCS = HostRootVMCS;
|
||||
//DEBUG((EFI_D_DEBUG, "%ld - GetRootVmxState: HostRootVmcs 0x%016llx\n", CpuIndex, RootState->HostRootVMCS));
|
||||
|
||||
RootGuestCR0_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_CR0_OFFSET);
|
||||
RootGuestCR3_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_CR3_OFFSET);
|
||||
RootGuestCR4_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_CR4_OFFSET);
|
||||
RootGuestGDTRBase_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_GDTR_BASE_OFFSET);
|
||||
RootGuestGDTRLimit_M = (*(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_32_GUEST_GDTR_LIMIT_OFFSET)) & 0x00000000FFFFFFFF;
|
||||
RootGuestIDTRBase_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_IDTR_BASE_OFFSET);
|
||||
RootGuestIDTRLimit_M = (*(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_32_GUEST_LDTR_LIMIT_OFFSET)) & 0x00000000FFFFFFFF;
|
||||
RootGuestRSP_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_RSP_OFFSET);
|
||||
RootGuestRIP_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_RIP_OFFSET);
|
||||
RootContExecVmcs_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_OFFSET);
|
||||
RootContLinkVmcs_M = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_64_GUEST_VMCS_LINK_PTR_OFFSET);
|
||||
RootGuestCR0_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_CR0_OFFSET);
|
||||
RootGuestCR3_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_CR3_OFFSET);
|
||||
RootGuestCR4_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_CR4_OFFSET);
|
||||
RootGuestGDTRBase_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_GDTR_BASE_OFFSET);
|
||||
RootGuestGDTRLimit_M = (*(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_32_GUEST_GDTR_LIMIT_OFFSET)) & 0x00000000FFFFFFFF;
|
||||
RootGuestIDTRBase_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_IDTR_BASE_OFFSET);
|
||||
RootGuestIDTRLimit_M = (*(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_32_GUEST_LDTR_LIMIT_OFFSET)) & 0x00000000FFFFFFFF;
|
||||
RootGuestRSP_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_RSP_OFFSET);
|
||||
RootGuestRIP_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_GUEST_RIP_OFFSET);
|
||||
RootContExecVmcs_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_OFFSET);
|
||||
RootContLinkVmcs_M = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_64_GUEST_VMCS_LINK_PTR_OFFSET);
|
||||
|
||||
#ifdef VMCSDEBUGPRINT
|
||||
if(RootState->VmcsType !=2) // only want active Vmcs
|
||||
{
|
||||
DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d) HostRootVmcs 0x%016llx\n G_CR0 %llx\n G_CR3 %llx\n G_CR4 %llx\n G_GDTR %llx:%llx\n G_IDTR %llx:%llx\n G_RSP %llx\n G_RIP %llx\n",
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld GetRootVmxState (%d) HostRootVmcs 0x%016llx\n G_CR0 %llx\n G_CR3 %llx\n G_CR4 %llx\n G_GDTR %llx:%llx\n G_IDTR %llx:%llx\n G_RSP %llx\n G_RIP %llx\n",
|
||||
CpuIndex,
|
||||
RootState->VmcsType,
|
||||
RootState->HostRootVMCS,
|
||||
|
@ -304,7 +319,8 @@ VmcsFlushStart:
|
|||
RootState->RootGuestRSP,
|
||||
RootState->RootGuestRIP));
|
||||
|
||||
DEBUG((EFI_D_DEBIG, "%ld GetRootVmxState (%d) (control) HostRootVmcs 0x%016llx\n VMXON %llx\n ExecutiveVMCS %llx\n LinkVMCS %llx\n EPT %llx\n",
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld GetRootVmxState (%d) (control) HostRootVmcs 0x%016llx\n VMXON %llx\n ExecutiveVMCS %llx\n LinkVMCS %llx\n EPT %llx\n",
|
||||
CpuIndex,
|
||||
RootState->VmcsType,
|
||||
RootState->HostRootVMCS,
|
||||
|
@ -313,9 +329,9 @@ VmcsFlushStart:
|
|||
RootState->LinkVMCS,
|
||||
RootState->RootContEPT));
|
||||
|
||||
DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d) (memory) HostRootVmcs 0x%016llx\n G_CR0m %llx\n G_CR3m %llx\n G_CR4m %llx\n G_GDTRm %llx:%llx\n G_IDTRm %llx:%llx\n G_RSPm %llx\n G_RIPm %llx\n",
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld GetRootVmxState (%d) (memory) HostRootVmcs 0x%016llx\n G_CR0m %llx\n G_CR3m %llx\n G_CR4m %llx\n G_GDTRm %llx:%llx\n G_IDTRm %llx:%llx\n G_RSPm %llx\n G_RIPm %llx\n",
|
||||
CpuIndex,
|
||||
// "GetRootVmxState (memory)\n G_CR0m %llx\n G_CR3m %llx\n G_CR4m %llx\n G_GDTRm %llx:%llx\n G_IDTRm %llx:%llx\n G_RSPm %llx\n G_RIPm %llx\n C_ExecVMCSm %llx\n C_LinkVMCSm %llx\n",
|
||||
RootState->VmcsType,
|
||||
RootState->HostRootVMCS,
|
||||
RootGuestCR0_M,
|
||||
|
@ -328,7 +344,8 @@ VmcsFlushStart:
|
|||
RootGuestRSP_M,
|
||||
RootGuestRIP_M));
|
||||
|
||||
DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d) (memory) HostRootVmcs 0x%016llx\n C_ExecVMCSm %llx\n C_LinkVMCSm %llx\n",
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld GetRootVmxState (%d) (memory) HostRootVmcs 0x%016llx\n C_ExecVMCSm %llx\n C_LinkVMCSm %llx\n",
|
||||
CpuIndex,
|
||||
RootState->VmcsType,
|
||||
RootState->HostRootVMCS,
|
||||
|
@ -336,8 +353,6 @@ VmcsFlushStart:
|
|||
RootContLinkVmcs_M));
|
||||
}
|
||||
#endif
|
||||
//DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState: VMCS_N_GUEST_RIP_MEMORY: 0x%016llx VMCS_N_GUEST_RIP: 0x%016llx, Location: 0x%016llx (test) \n",
|
||||
// CpuIndex, RootGuestRIP_M, RootState->RootGuestRIP, ((UINTN)HostRootVMCS + (UINTN)VMCS_N_GUEST_RIP_OFFSET)));
|
||||
|
||||
// need to save the root vmx host structures
|
||||
#ifdef ZERO
|
||||
|
@ -356,15 +371,23 @@ VmcsFlushStart:
|
|||
else
|
||||
#endif
|
||||
{
|
||||
RootState->RootHostCR0 = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_CR0_OFFSET);
|
||||
RootState->RootHostCR3 = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_CR3_OFFSET);
|
||||
RootState->RootHostCR4 = *(UINT64 *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_CR4_OFFSET);
|
||||
RootState->RootHostGDTRBase = *(UINTN *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_GDTR_BASE_OFFSET);
|
||||
RootState->RootHostIDTRBase = *(UINTN *)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_IDTR_BASE_OFFSET);
|
||||
RootState->RootHostCR0 = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_CR0_OFFSET);
|
||||
RootState->RootHostCR3 = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_CR3_OFFSET);
|
||||
RootState->RootHostCR4 = *(UINT64 *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_CR4_OFFSET);
|
||||
RootState->RootHostGDTRBase = *(UINTN *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_GDTR_BASE_OFFSET);
|
||||
RootState->RootHostIDTRBase = *(UINTN *)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_IDTR_BASE_OFFSET);
|
||||
|
||||
RootState->RootHostRSP = *(UINTN*)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_RSP_OFFSET);
|
||||
RootState->RootHostRIP = *(UINTN*)((UINTN)HostRootVMCS + (UINTN)VMCS_N_HOST_RIP_OFFSET);
|
||||
RootState->RootHostEPT = *(UINTN*)((UINTN)HostRootVMCS + (UINTN)VMCS_64_CONTROL_EPT_PTR_OFFSET);
|
||||
RootState->RootHostRSP = *(UINTN*)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_RSP_OFFSET);
|
||||
RootState->RootHostRIP = *(UINTN*)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_N_HOST_RIP_OFFSET);
|
||||
RootState->RootHostEPT = *(UINTN*)((UINTN)HostRootVMCS +
|
||||
(UINTN)VMCS_64_CONTROL_EPT_PTR_OFFSET);
|
||||
}
|
||||
// Indicate to the master that we are all done
|
||||
|
||||
|
@ -377,7 +400,8 @@ VmcsFlushStart:
|
|||
#ifdef VMCSDEBUGPRINT
|
||||
if(RootState->VmcsType != 2)
|
||||
{
|
||||
DEBUG((EFI_D_DEBUG, "%ld GetRootVmxState (%d) \n H_CR0 %llx\n H_CR3 %llx\n H_CR4 %llx\n H_GDTR %llx\n H_IDTR %llx\n H_RSP %llx\n H_RIP %llx\n H_EPT %llx\n",
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld GetRootVmxState (%d) \n H_CR0 %llx\n H_CR3 %llx\n H_CR4 %llx\n H_GDTR %llx\n H_IDTR %llx\n H_RSP %llx\n H_RIP %llx\n H_EPT %llx\n",
|
||||
CpuIndex,
|
||||
RootState->VmcsType,
|
||||
RootState->RootHostCR0,
|
||||
|
@ -422,17 +446,20 @@ void SetupGetRootVmxState()
|
|||
VMCS_N_GUEST_IDTR_BASE_OFFSET = GetVmcsOffset(VMCS_N_GUEST_IDTR_BASE_INDEX);
|
||||
VMCS_32_GUEST_LDTR_LIMIT_OFFSET = GetVmcsOffset(VMCS_32_GUEST_LDTR_LIMIT_INDEX);
|
||||
VMCS_N_GUEST_RSP_OFFSET = GetVmcsOffset(VMCS_N_GUEST_RSP_INDEX);
|
||||
VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_OFFSET = GetVmcsOffset(VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_INDEX);
|
||||
VMCS_64_GUEST_VMCS_LINK_PTR_OFFSET = GetVmcsOffset(VMCS_64_GUEST_VMCS_LINK_PTR_INDEX);
|
||||
VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_OFFSET =
|
||||
GetVmcsOffset(VMCS_64_CONTROL_EXECUTIVE_VMCS_PTR_INDEX);
|
||||
VMCS_64_GUEST_VMCS_LINK_PTR_OFFSET =
|
||||
GetVmcsOffset(VMCS_64_GUEST_VMCS_LINK_PTR_INDEX);
|
||||
// need to initialize the VMCS Offset table, if it has not already been done
|
||||
VMCS_OFFSET_READY = 1;
|
||||
}
|
||||
|
||||
void PrintVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState)
|
||||
{
|
||||
if(RootState->ExecutiveVMCS == RootState->Vmxon) // ref: section 34.15.4.7
|
||||
if(RootState->ExecutiveVMCS == RootState->Vmxon)// ref: section 34.15.4.7
|
||||
{
|
||||
// we are in root operation, so our VMCS of interest is in the VNCS-Link field
|
||||
// we are in root operation,
|
||||
//so our VMCS of interest is in the VNCS-Link field
|
||||
|
||||
if(RootState->LinkVMCS != 0xFFFFFFFFFFFFFFFF)
|
||||
{
|
||||
|
@ -453,7 +480,8 @@ void PrintVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState)
|
|||
}
|
||||
else
|
||||
{
|
||||
// in guest operation, so our VMCS of interest is in the executive-VMCS field
|
||||
// in guest operation,
|
||||
// so our VMCS of interest is in the executive-VMCS field
|
||||
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld PrintVmxState (%d): execVMCS is guest VMCS: 0x%016llx using Executive VMCS\n",
|
||||
|
@ -489,7 +517,8 @@ void PrintVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState)
|
|||
RootState->LinkVMCS,
|
||||
RootState->RootContEPT));
|
||||
|
||||
DEBUG((EFI_D_INFO, "%ld PrintVmxState (%d) \n H_CR0 %llx\n H_CR3 %llx\n H_CR4 %llx\n H_GDTR %llx\n H_IDTR %llx\n H_RSP %llx\n H_RIP %llx\n H_EPT %llx\n",
|
||||
DEBUG((EFI_D_INFO,
|
||||
"%ld PrintVmxState (%d) \n H_CR0 %llx\n H_CR3 %llx\n H_CR4 %llx\n H_GDTR %llx\n H_IDTR %llx\n H_RSP %llx\n H_RIP %llx\n H_EPT %llx\n",
|
||||
CpuIndex,
|
||||
RootState->VmcsType,
|
||||
RootState->RootHostCR0,
|
||||
|
@ -503,4 +532,3 @@ void PrintVmxState(UINT32 CpuIndex, ROOT_VMX_STATE * RootState)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue