HyperPlatform Programmer's Reference
Functions
vm.cpp File Reference

Implements VMM initialization functions. More...

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

Go to the source code of this file.

Functions

static bool VmpIsVmxAvailable ()
 
static NTSTATUS VmpSetLockBitCallback (_In_opt_ void *context)
 
static SharedProcessorDataVmpInitializeSharedData ()
 
static void * VmpBuildMsrBitmap ()
 
static UCHAR * VmpBuildIoBitmaps ()
 
static NTSTATUS VmpStartVm (_In_opt_ void *context)
 
static void VmpInitializeVm (_In_ ULONG_PTR guest_stack_pointer, _In_ ULONG_PTR guest_instruction_pointer, _In_opt_ void *context)
 
static bool VmpEnterVmxMode (_Inout_ ProcessorData *processor_data)
 
static bool VmpInitializeVmcs (_Inout_ ProcessorData *processor_data)
 
static bool VmpSetupVmcs (_In_ const ProcessorData *processor_data, _In_ ULONG_PTR guest_stack_pointer, _In_ ULONG_PTR guest_instruction_pointer, _In_ ULONG_PTR vmm_stack_pointer)
 
static void VmpLaunchVm ()
 
static ULONG VmpGetSegmentAccessRight (_In_ USHORT segment_selector)
 
static ULONG_PTR VmpGetSegmentBase (_In_ ULONG_PTR gdt_base, _In_ USHORT segment_selector)
 
static SegmentDescriptorVmpGetSegmentDescriptor (_In_ ULONG_PTR descriptor_table_base, _In_ USHORT segment_selector)
 
static ULONG_PTR VmpGetSegmentBaseByDescriptor (_In_ const SegmentDescriptor *segment_descriptor)
 
static ULONG VmpAdjustControlValue (_In_ Msr msr, _In_ ULONG requested_value)
 
static NTSTATUS VmpStopVm (_In_opt_ void *context)
 
static void VmpFreeProcessorData (_In_opt_ ProcessorData *processor_data)
 
static void VmpFreeSharedData (_In_ ProcessorData *processor_data)
 
static bool VmpIsHyperPlatformInstalled ()
 
ULONG GetSegmentLimit (_In_ ULONG selector)
 
NTSTATUS VmInitialization ()
 Virtualizes all processors. More...
 
static NTSTATUS VmpSetLockBitCallback (void *context)
 
static NTSTATUS VmpStartVm (void *context)
 
static void VmpInitializeVm (ULONG_PTR guest_stack_pointer, ULONG_PTR guest_instruction_pointer, void *context)
 
static bool VmpEnterVmxMode (ProcessorData *processor_data)
 
static bool VmpInitializeVmcs (ProcessorData *processor_data)
 
static bool VmpSetupVmcs (const ProcessorData *processor_data, ULONG_PTR guest_stack_pointer, ULONG_PTR guest_instruction_pointer, ULONG_PTR vmm_stack_pointer)
 
static ULONG VmpGetSegmentAccessRight (USHORT segment_selector)
 
static ULONG_PTR VmpGetSegmentBase (ULONG_PTR gdt_base, USHORT segment_selector)
 
static SegmentDescriptorVmpGetSegmentDescriptor (ULONG_PTR descriptor_table_base, USHORT segment_selector)
 
static ULONG_PTR VmpGetSegmentBaseByDescriptor (const SegmentDescriptor *segment_descriptor)
 
static ULONG VmpAdjustControlValue (Msr msr, ULONG requested_value)
 
void VmTermination ()
 De-virtualize all processors. More...
 
static NTSTATUS VmpStopVm (void *context)
 
static void VmpFreeProcessorData (ProcessorData *processor_data)
 
static void VmpFreeSharedData (ProcessorData *processor_data)
 
NTSTATUS VmHotplugCallback (const PROCESSOR_NUMBER &proc_num)
 Virtualizes the specified processor. More...
 

Detailed Description

Implements VMM initialization functions.

Definition in file vm.cpp.

Function Documentation

◆ GetSegmentLimit()

ULONG GetSegmentLimit ( _In_ ULONG  selector)
inline

Definition at line 137 of file vm.cpp.

Here is the caller graph for this function:

◆ VmHotplugCallback()

NTSTATUS VmHotplugCallback ( const PROCESSOR_NUMBER &  proc_num)

Virtualizes the specified processor.

Parameters
proc_numA processor number to virtualize
Returns
STATUS_SUCCESS on success

The processor 0 must have already been virtualized, or it fails.

Definition at line 997 of file vm.cpp.

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

◆ VmInitialization()

NTSTATUS VmInitialization ( )

Virtualizes all processors.

Returns
STATUS_SUCCESS on success

Initializes a VMCS region and virtualizes (ie, enters the VMX non-root operation mode) for each processor. Returns non STATUS_SUCCESS value if any of processors failed to do so. In that case, this function de-virtualize already virtualized processors.

Definition at line 143 of file vm.cpp.

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

◆ VmpAdjustControlValue() [1/2]

static ULONG VmpAdjustControlValue ( _In_ Msr  msr,
_In_ ULONG  requested_value 
)
static
Here is the caller graph for this function:

◆ VmpAdjustControlValue() [2/2]

static ULONG VmpAdjustControlValue ( Msr  msr,
ULONG  requested_value 
)
static

Definition at line 874 of file vm.cpp.

Here is the call graph for this function:

◆ VmpBuildIoBitmaps()

static UCHAR * VmpBuildIoBitmaps ( )
static

Definition at line 313 of file vm.cpp.

Here is the caller graph for this function:

◆ VmpBuildMsrBitmap()

static void * VmpBuildMsrBitmap ( )
static

Definition at line 269 of file vm.cpp.

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

◆ VmpEnterVmxMode() [1/2]

static bool VmpEnterVmxMode ( _Inout_ ProcessorData processor_data)
static
Here is the caller graph for this function:

◆ VmpEnterVmxMode() [2/2]

static bool VmpEnterVmxMode ( ProcessorData processor_data)
static

Definition at line 468 of file vm.cpp.

Here is the call graph for this function:

◆ VmpFreeProcessorData() [1/2]

static void VmpFreeProcessorData ( _In_opt_ ProcessorData processor_data)
static
Here is the caller graph for this function:

◆ VmpFreeProcessorData() [2/2]

static void VmpFreeProcessorData ( ProcessorData processor_data)
static

Definition at line 928 of file vm.cpp.

Here is the call graph for this function:

◆ VmpFreeSharedData() [1/2]

static void VmpFreeSharedData ( _In_ ProcessorData processor_data)
static
Here is the caller graph for this function:

◆ VmpFreeSharedData() [2/2]

static void VmpFreeSharedData ( ProcessorData processor_data)
static

Definition at line 955 of file vm.cpp.

◆ VmpGetSegmentAccessRight() [1/2]

static ULONG VmpGetSegmentAccessRight ( _In_ USHORT  segment_selector)
static
Here is the caller graph for this function:

◆ VmpGetSegmentAccessRight() [2/2]

static ULONG VmpGetSegmentAccessRight ( USHORT  segment_selector)
static

Definition at line 799 of file vm.cpp.

Here is the call graph for this function:

◆ VmpGetSegmentBase() [1/2]

static ULONG_PTR VmpGetSegmentBase ( _In_ ULONG_PTR  gdt_base,
_In_ USHORT  segment_selector 
)
static
Here is the caller graph for this function:

◆ VmpGetSegmentBase() [2/2]

static ULONG_PTR VmpGetSegmentBase ( ULONG_PTR  gdt_base,
USHORT  segment_selector 
)
static

Definition at line 819 of file vm.cpp.

Here is the call graph for this function:

◆ VmpGetSegmentBaseByDescriptor() [1/2]

static ULONG_PTR VmpGetSegmentBaseByDescriptor ( _In_ const SegmentDescriptor segment_descriptor)
static
Here is the caller graph for this function:

◆ VmpGetSegmentBaseByDescriptor() [2/2]

static ULONG_PTR VmpGetSegmentBaseByDescriptor ( const SegmentDescriptor segment_descriptor)
static

Definition at line 854 of file vm.cpp.

Here is the call graph for this function:

◆ VmpGetSegmentDescriptor() [1/2]

static SegmentDescriptor* VmpGetSegmentDescriptor ( _In_ ULONG_PTR  descriptor_table_base,
_In_ USHORT  segment_selector 
)
static
Here is the caller graph for this function:

◆ VmpGetSegmentDescriptor() [2/2]

static SegmentDescriptor* VmpGetSegmentDescriptor ( ULONG_PTR  descriptor_table_base,
USHORT  segment_selector 
)
static

Definition at line 844 of file vm.cpp.

◆ VmpInitializeSharedData()

static SharedProcessorData * VmpInitializeSharedData ( )
static

Definition at line 237 of file vm.cpp.

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

◆ VmpInitializeVm() [1/2]

static void VmpInitializeVm ( _In_ ULONG_PTR  guest_stack_pointer,
_In_ ULONG_PTR  guest_instruction_pointer,
_In_opt_ void *  context 
)
static
Here is the caller graph for this function:

◆ VmpInitializeVm() [2/2]

static void VmpInitializeVm ( ULONG_PTR  guest_stack_pointer,
ULONG_PTR  guest_instruction_pointer,
void *  context 
)
static

Definition at line 358 of file vm.cpp.

Here is the call graph for this function:

◆ VmpInitializeVmcs() [1/2]

static bool VmpInitializeVmcs ( _Inout_ ProcessorData processor_data)
static
Here is the caller graph for this function:

◆ VmpInitializeVmcs() [2/2]

static bool VmpInitializeVmcs ( ProcessorData processor_data)
static

Definition at line 524 of file vm.cpp.

Here is the call graph for this function:

◆ VmpIsHyperPlatformInstalled()

static bool VmpIsHyperPlatformInstalled ( )
static

Definition at line 981 of file vm.cpp.

Here is the caller graph for this function:

◆ VmpIsVmxAvailable()

static bool VmpIsVmxAvailable ( )
static

Definition at line 172 of file vm.cpp.

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

◆ VmpLaunchVm()

static void VmpLaunchVm ( )
static

Definition at line 779 of file vm.cpp.

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

◆ VmpSetLockBitCallback() [1/2]

static NTSTATUS VmpSetLockBitCallback ( _In_opt_ void *  context)
static
Here is the caller graph for this function:

◆ VmpSetLockBitCallback() [2/2]

static NTSTATUS VmpSetLockBitCallback ( void *  context)
static

Definition at line 217 of file vm.cpp.

Here is the call graph for this function:

◆ VmpSetupVmcs() [1/2]

static bool VmpSetupVmcs ( _In_ const ProcessorData processor_data,
_In_ ULONG_PTR  guest_stack_pointer,
_In_ ULONG_PTR  guest_instruction_pointer,
_In_ ULONG_PTR  vmm_stack_pointer 
)
static
Here is the caller graph for this function:

◆ VmpSetupVmcs() [2/2]

static bool VmpSetupVmcs ( const ProcessorData processor_data,
ULONG_PTR  guest_stack_pointer,
ULONG_PTR  guest_instruction_pointer,
ULONG_PTR  vmm_stack_pointer 
)
static

Definition at line 546 of file vm.cpp.

Here is the call graph for this function:

◆ VmpStartVm() [1/2]

static NTSTATUS VmpStartVm ( _In_opt_ void *  context)
static
Here is the caller graph for this function:

◆ VmpStartVm() [2/2]

static NTSTATUS VmpStartVm ( void *  context)
static

Definition at line 342 of file vm.cpp.

Here is the call graph for this function:

◆ VmpStopVm() [1/2]

static NTSTATUS VmpStopVm ( _In_opt_ void *  context)
static
Here is the caller graph for this function:

◆ VmpStopVm() [2/2]

static NTSTATUS VmpStopVm ( void *  context)
static

Definition at line 904 of file vm.cpp.

Here is the call graph for this function:

◆ VmTermination()

void VmTermination ( )

De-virtualize all processors.

Definition at line 890 of file vm.cpp.

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