HyperPlatform Programmer's Reference
Classes | Functions | Variables
vmm.cpp File Reference

Implements VMM functions. More...

#include "vmm.h"
#include <intrin.h>
#include "asm.h"
#include "common.h"
#include "ept.h"
#include "log.h"
#include "util.h"
#include "performance.h"
Include dependency graph for vmm.cpp:

Go to the source code of this file.

Classes

struct  VmmInitialStack
 
struct  GuestContext
 
struct  VmExitHistory
 

Functions

bool __stdcall VmmVmExitHandler (_Inout_ VmmInitialStack *stack)
 
DECLSPEC_NORETURN void __stdcall VmmVmxFailureHandler (_Inout_ AllRegisters *all_regs)
 
static void VmmpHandleVmExit (_Inout_ GuestContext *guest_context)
 
static DECLSPEC_NORETURN void VmmpHandleTripleFault (_Inout_ GuestContext *guest_context)
 
static DECLSPEC_NORETURN void VmmpHandleUnexpectedExit (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleMonitorTrap (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleException (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleCpuid (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleRdtsc (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleRdtscp (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleXsetbv (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleMsrReadAccess (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleMsrWriteAccess (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleMsrAccess (_Inout_ GuestContext *guest_context, _In_ bool read_access)
 
static void VmmpHandleGdtrOrIdtrAccess (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleLdtrOrTrAccess (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleDrAccess (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleIoPort (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleCrAccess (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleVmx (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleVmCall (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleInvalidateInternalCaches (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleInvalidateTlbEntry (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleEptViolation (_Inout_ GuestContext *guest_context)
 
static void VmmpHandleEptMisconfig (_Inout_ GuestContext *guest_context)
 
static ULONG_PTR * VmmpSelectRegister (_In_ ULONG index, _In_ GuestContext *guest_context)
 
static void VmmpDumpGuestState ()
 
static void VmmpAdjustGuestInstructionPointer (_In_ GuestContext *guest_context)
 
static void VmmpIoWrapper (_In_ bool to_memory, _In_ bool is_string, _In_ SIZE_T size_of_access, _In_ unsigned short port, _Inout_ void *address, _In_ unsigned long count)
 
static void VmmpIndicateSuccessfulVmcall (_In_ GuestContext *guest_context)
 
static void VmmpIndicateUnsuccessfulVmcall (_In_ GuestContext *guest_context)
 
static void VmmpHandleVmCallTermination (_In_ GuestContext *guest_context, _Inout_ void *context)
 
static UCHAR VmmpGetGuestCpl ()
 
static void VmmpInjectInterruption (_In_ InterruptionType interruption_type, _In_ InterruptionVector vector, _In_ bool deliver_error_code, _In_ ULONG32 error_code)
 
static ULONG_PTR VmmpGetKernelCr3 ()
 
bool __stdcall VmmVmExitHandler (VmmInitialStack *stack)
 
static void VmmpHandleVmExit (GuestContext *guest_context)
 
static void VmmpHandleTripleFault (GuestContext *guest_context)
 
static void VmmpHandleUnexpectedExit (GuestContext *guest_context)
 
static void VmmpHandleMonitorTrap (GuestContext *guest_context)
 
static void VmmpHandleException (GuestContext *guest_context)
 
static void VmmpHandleCpuid (GuestContext *guest_context)
 
static void VmmpHandleRdtsc (GuestContext *guest_context)
 
static void VmmpHandleRdtscp (GuestContext *guest_context)
 
static void VmmpHandleXsetbv (GuestContext *guest_context)
 
static void VmmpHandleMsrReadAccess (GuestContext *guest_context)
 
static void VmmpHandleMsrWriteAccess (GuestContext *guest_context)
 
static void VmmpHandleMsrAccess (GuestContext *guest_context, bool read_access)
 
static void VmmpHandleGdtrOrIdtrAccess (GuestContext *guest_context)
 
static void VmmpHandleLdtrOrTrAccess (GuestContext *guest_context)
 
static void VmmpHandleDrAccess (GuestContext *guest_context)
 
static void VmmpHandleIoPort (GuestContext *guest_context)
 
static void VmmpIoWrapper (bool to_memory, bool is_string, SIZE_T size_of_access, unsigned short port, void *address, unsigned long count)
 
static void VmmpHandleCrAccess (GuestContext *guest_context)
 
static void VmmpHandleVmx (GuestContext *guest_context)
 
static void VmmpHandleVmCall (GuestContext *guest_context)
 
static void VmmpHandleInvalidateInternalCaches (GuestContext *guest_context)
 
static void VmmpHandleInvalidateTlbEntry (GuestContext *guest_context)
 
static void VmmpHandleEptViolation (GuestContext *guest_context)
 
static void VmmpHandleEptMisconfig (GuestContext *guest_context)
 
static ULONG_PTR * VmmpSelectRegister (ULONG index, GuestContext *guest_context)
 
static void VmmpAdjustGuestInstructionPointer (GuestContext *guest_context)
 
void __stdcall VmmVmxFailureHandler (AllRegisters *all_regs)
 
static void VmmpIndicateSuccessfulVmcall (GuestContext *guest_context)
 
static void VmmpIndicateUnsuccessfulVmcall (GuestContext *guest_context)
 
static void VmmpHandleVmCallTermination (GuestContext *guest_context, void *context)
 
static void VmmpInjectInterruption (InterruptionType interruption_type, InterruptionVector vector, bool deliver_error_code, ULONG32 error_code)
 

Variables

static const bool kVmmpEnableRecordVmExit = false
 
static const long kVmmpNumberOfRecords = 100
 
static const long kVmmpNumberOfProcessors = 2
 
static ULONG g_vmmp_next_history_index [kVmmpNumberOfProcessors]
 
static VmExitHistory g_vmmp_vm_exit_history [kVmmpNumberOfProcessors][kVmmpNumberOfRecords]
 

Detailed Description

Implements VMM functions.

Definition in file vmm.cpp.

Function Documentation

◆ VmmpAdjustGuestInstructionPointer() [1/2]

static void VmmpAdjustGuestInstructionPointer ( _In_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpAdjustGuestInstructionPointer() [2/2]

static void VmmpAdjustGuestInstructionPointer ( GuestContext guest_context)
static

Definition at line 1316 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpDumpGuestState()

static void VmmpDumpGuestState ( )
static

Definition at line 1258 of file vmm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VmmpGetGuestCpl()

static UCHAR VmmpGetGuestCpl ( )
static

Definition at line 1418 of file vmm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VmmpGetKernelCr3()

static ULONG_PTR VmmpGetKernelCr3 ( )
static

Definition at line 1441 of file vmm.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VmmpHandleCpuid() [1/2]

static void VmmpHandleCpuid ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleCpuid() [2/2]

static void VmmpHandleCpuid ( GuestContext guest_context)
static

Definition at line 407 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleCrAccess() [1/2]

static void VmmpHandleCrAccess ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleCrAccess() [2/2]

static void VmmpHandleCrAccess ( GuestContext guest_context)
static

Definition at line 1022 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleDrAccess() [1/2]

static void VmmpHandleDrAccess ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleDrAccess() [2/2]

static void VmmpHandleDrAccess ( GuestContext guest_context)
static

Definition at line 761 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleEptMisconfig() [1/2]

static void VmmpHandleEptMisconfig ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleEptMisconfig() [2/2]

static void VmmpHandleEptMisconfig ( GuestContext guest_context)
static

Definition at line 1215 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleEptViolation() [1/2]

static void VmmpHandleEptViolation ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleEptViolation() [2/2]

static void VmmpHandleEptViolation ( GuestContext guest_context)
static

Definition at line 1207 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleException() [1/2]

static void VmmpHandleException ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleException() [2/2]

static void VmmpHandleException ( GuestContext guest_context)
static

Definition at line 351 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleGdtrOrIdtrAccess() [1/2]

static void VmmpHandleGdtrOrIdtrAccess ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleGdtrOrIdtrAccess() [2/2]

static void VmmpHandleGdtrOrIdtrAccess ( GuestContext guest_context)
static

Definition at line 559 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleInvalidateInternalCaches() [1/2]

static void VmmpHandleInvalidateInternalCaches ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleInvalidateInternalCaches() [2/2]

static void VmmpHandleInvalidateInternalCaches ( GuestContext guest_context)
static

Definition at line 1186 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleInvalidateTlbEntry() [1/2]

static void VmmpHandleInvalidateTlbEntry ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleInvalidateTlbEntry() [2/2]

static void VmmpHandleInvalidateTlbEntry ( GuestContext guest_context)
static

Definition at line 1194 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleIoPort() [1/2]

static void VmmpHandleIoPort ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleIoPort() [2/2]

static void VmmpHandleIoPort ( GuestContext guest_context)
static

Definition at line 905 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleLdtrOrTrAccess() [1/2]

static void VmmpHandleLdtrOrTrAccess ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleLdtrOrTrAccess() [2/2]

static void VmmpHandleLdtrOrTrAccess ( GuestContext guest_context)
static

Definition at line 655 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleMonitorTrap() [1/2]

static void VmmpHandleMonitorTrap ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleMonitorTrap() [2/2]

static void VmmpHandleMonitorTrap ( GuestContext guest_context)
static

Definition at line 342 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleMsrAccess() [1/2]

static void VmmpHandleMsrAccess ( _Inout_ GuestContext guest_context,
_In_ bool  read_access 
)
static
Here is the caller graph for this function:

◆ VmmpHandleMsrAccess() [2/2]

static void VmmpHandleMsrAccess ( GuestContext guest_context,
bool  read_access 
)
static

Definition at line 487 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleMsrReadAccess() [1/2]

static void VmmpHandleMsrReadAccess ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleMsrReadAccess() [2/2]

static void VmmpHandleMsrReadAccess ( GuestContext guest_context)
static

Definition at line 473 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleMsrWriteAccess() [1/2]

static void VmmpHandleMsrWriteAccess ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleMsrWriteAccess() [2/2]

static void VmmpHandleMsrWriteAccess ( GuestContext guest_context)
static

Definition at line 480 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleRdtsc() [1/2]

static void VmmpHandleRdtsc ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleRdtsc() [2/2]

static void VmmpHandleRdtsc ( GuestContext guest_context)
static

Definition at line 435 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleRdtscp() [1/2]

static void VmmpHandleRdtscp ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleRdtscp() [2/2]

static void VmmpHandleRdtscp ( GuestContext guest_context)
static

Definition at line 447 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleTripleFault() [1/2]

static DECLSPEC_NORETURN void VmmpHandleTripleFault ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleTripleFault() [2/2]

static void VmmpHandleTripleFault ( GuestContext guest_context)
static

Definition at line 323 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleUnexpectedExit() [1/2]

static DECLSPEC_NORETURN void VmmpHandleUnexpectedExit ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleUnexpectedExit() [2/2]

static void VmmpHandleUnexpectedExit ( GuestContext guest_context)
static

Definition at line 332 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleVmCall() [1/2]

static void VmmpHandleVmCall ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleVmCall() [2/2]

static void VmmpHandleVmCall ( GuestContext guest_context)
static

Definition at line 1150 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleVmCallTermination() [1/2]

static void VmmpHandleVmCallTermination ( _In_ GuestContext guest_context,
_Inout_ void *  context 
)
static
Here is the caller graph for this function:

◆ VmmpHandleVmCallTermination() [2/2]

static void VmmpHandleVmCallTermination ( GuestContext guest_context,
void *  context 
)
static

Definition at line 1369 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleVmExit() [1/2]

static void VmmpHandleVmExit ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleVmExit() [2/2]

static void VmmpHandleVmExit ( GuestContext guest_context)
static

Definition at line 224 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleVmx() [1/2]

static void VmmpHandleVmx ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleVmx() [2/2]

static void VmmpHandleVmx ( GuestContext guest_context)
static

Definition at line 1136 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpHandleXsetbv() [1/2]

static void VmmpHandleXsetbv ( _Inout_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpHandleXsetbv() [2/2]

static void VmmpHandleXsetbv ( GuestContext guest_context)
static

Definition at line 461 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpIndicateSuccessfulVmcall() [1/2]

static void VmmpIndicateSuccessfulVmcall ( _In_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpIndicateSuccessfulVmcall() [2/2]

static void VmmpIndicateSuccessfulVmcall ( GuestContext guest_context)
static

Definition at line 1343 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpIndicateUnsuccessfulVmcall() [1/2]

static void VmmpIndicateUnsuccessfulVmcall ( _In_ GuestContext guest_context)
static
Here is the caller graph for this function:

◆ VmmpIndicateUnsuccessfulVmcall() [2/2]

static void VmmpIndicateUnsuccessfulVmcall ( GuestContext guest_context)
static

Definition at line 1359 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpInjectInterruption() [1/2]

static void VmmpInjectInterruption ( _In_ InterruptionType  interruption_type,
_In_ InterruptionVector  vector,
_In_ bool  deliver_error_code,
_In_ ULONG32  error_code 
)
static
Here is the caller graph for this function:

◆ VmmpInjectInterruption() [2/2]

static void VmmpInjectInterruption ( InterruptionType  interruption_type,
InterruptionVector  vector,
bool  deliver_error_code,
ULONG32  error_code 
)
static

Definition at line 1425 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpIoWrapper() [1/2]

static void VmmpIoWrapper ( _In_ bool  to_memory,
_In_ bool  is_string,
_In_ SIZE_T  size_of_access,
_In_ unsigned short  port,
_Inout_ void *  address,
_In_ unsigned long  count 
)
static
Here is the caller graph for this function:

◆ VmmpIoWrapper() [2/2]

static void VmmpIoWrapper ( bool  to_memory,
bool  is_string,
SIZE_T  size_of_access,
unsigned short  port,
void *  address,
unsigned long  count 
)
static

Definition at line 969 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmpSelectRegister() [1/2]

static ULONG_PTR* VmmpSelectRegister ( _In_ ULONG  index,
_In_ GuestContext guest_context 
)
static
Here is the caller graph for this function:

◆ VmmpSelectRegister() [2/2]

static ULONG_PTR* VmmpSelectRegister ( ULONG  index,
GuestContext guest_context 
)
static

Definition at line 1228 of file vmm.cpp.

◆ VmmVmExitHandler() [1/2]

bool __stdcall VmmVmExitHandler ( _Inout_ VmmInitialStack stack)

◆ VmmVmExitHandler() [2/2]

bool __stdcall VmmVmExitHandler ( VmmInitialStack stack)

Definition at line 182 of file vmm.cpp.

Here is the call graph for this function:

◆ VmmVmxFailureHandler() [1/2]

DECLSPEC_NORETURN void __stdcall VmmVmxFailureHandler ( _Inout_ AllRegisters all_regs)

◆ VmmVmxFailureHandler() [2/2]

void __stdcall VmmVmxFailureHandler ( AllRegisters all_regs)

Definition at line 1330 of file vmm.cpp.

Here is the call graph for this function:

Variable Documentation

◆ g_vmmp_next_history_index

ULONG g_vmmp_next_history_index[kVmmpNumberOfProcessors]
static

Definition at line 169 of file vmm.cpp.

◆ g_vmmp_vm_exit_history

Definition at line 171 of file vmm.cpp.

◆ kVmmpEnableRecordVmExit

const bool kVmmpEnableRecordVmExit = false
static

Definition at line 29 of file vmm.cpp.

◆ kVmmpNumberOfProcessors

const long kVmmpNumberOfProcessors = 2
static

Definition at line 35 of file vmm.cpp.

◆ kVmmpNumberOfRecords

const long kVmmpNumberOfRecords = 100
static

Definition at line 32 of file vmm.cpp.