Core/Init/StmInit.c - Clear possible VMCS cache residue

Make sure that cache VMCS residue is cleared from the processor.

This can affect the STM VM's when the STM is torn down when the
proessor is suspended.  In this instance the processor may hold
in it's VMCS cache the previous SMI and SMM VMCS's, which if not
cleared can corrupt the new VMCS and cause unpredicatable actions
to occur.

Signed-off-by: Eugene Myers <edmyers@tycho.nsa.gov>
This commit is contained in:
Eugene Myers 2022-09-13 13:19:02 -04:00
parent 55106defc3
commit 449be74faf
1 changed files with 12 additions and 2 deletions

View File

@ -1159,8 +1159,18 @@ VmcsInit (
if ((Rflags & (RFLAGS_CF | RFLAGS_ZF)) != 0) {
DEBUG ((EFI_D_ERROR, "%d ERROR: AsmVmClear - %016lx : %08x\n", (UINTN)Index, CurrentVmcs, Rflags));
CpuDeadLoop ();
}
}
/* clear possible cache residue from previous incarnation of STM */
Rflags = AsmVmClear ((VOID *)(UINTN) &mGuestContextCommonSmi.GuestContextPerCpu[Index].Vmcs);
if ((Rflags & (RFLAGS_CF | RFLAGS_ZF)) != 0) {
DEBUG ((EFI_D_ERROR, "%d : Warning AsmVmClear - %016lx : %08x\n", (UINTN)Index,
(VOID *)(UINTN)mGuestContextCommonSmi.GuestContextPerCpu[Index].Vmcs,
Rflags));
}
AsmVmClear((VOID *) (UINTN) &mGuestContextCommonSmm[SMI_HANDLER].GuestContextPerCpu[Index].Vmcs);
CopyMem (
(VOID *)(UINTN)mGuestContextCommonSmi.GuestContextPerCpu[Index].Vmcs,
(VOID *)(UINTN)CurrentVmcs,