L4Re - L4 Runtime Environment

Virtual machine API for VMX. More...

+ Collaboration diagram for VM API for VMX:

Enumerations

enum  L4_vm_vmx_caps_regs {
  L4_VM_VMX_BASIC_REG = 0, L4_VM_VMX_TRUE_PINBASED_CTLS_REG = 1, L4_VM_VMX_TRUE_PROCBASED_CTLS_REG = 2, L4_VM_VMX_TRUE_EXIT_CTLS_REG = 3,
  L4_VM_VMX_TRUE_ENTRY_CTLS_REG = 4, L4_VM_VMX_MISC_REG = 5, L4_VM_VMX_CR0_FIXED0_REG = 6, L4_VM_VMX_CR0_FIXED1_REG = 7,
  L4_VM_VMX_CR4_FIXED0_REG = 8, L4_VM_VMX_CR4_FIXED1_REG = 9, L4_VM_VMX_VMCS_ENUM_REG = 0xa, L4_VM_VMX_PROCBASED_CTLS2_REG = 0xb,
  L4_VM_VMX_EPT_VPID_CAP_REG = 0xc, L4_VM_VMX_NUM_CAPS_REGS
}
 Exported VMX capability registers. More...
 
enum  L4_vm_vmx_dfl1_regs {
  L4_VM_VMX_PINBASED_CTLS_DFL1_REG = 0x1, L4_VM_VMX_PROCBASED_CTLS_DFL1_REG = 0x2, L4_VM_VMX_EXIT_CTLS_DFL1_REG = 0x3, L4_VM_VMX_ENTRY_CTLS_DFL1_REG = 0x4,
  L4_VM_VMX_NUM_DFL1_REGS
}
 Exported VMX capability registers (default to 1 bits). More...
 
enum  {
  L4_VM_VMX_VMCS_CR2 = 0x683e, L4_VM_VMX_VMCS_XCR0 = 0x2840, L4_VM_VMX_VMCS_MSR_SYSCALL_MASK = 0x2842, L4_VM_VMX_VMCS_MSR_LSTAR = 0x2844,
  L4_VM_VMX_VMCS_MSR_CSTAR = 0x2846, L4_VM_VMX_VMCS_MSR_TSC_AUX = 0x2848, L4_VM_VMX_VMCS_MSR_STAR = 0x284a, L4_VM_VMX_VMCS_MSR_KERNEL_GS_BASE = 0x284c
}
 Additional (virtual) VMCS fields. More...
 

Functions

l4_uint64_t l4_vm_vmx_get_caps (void const *vcpu_state, unsigned cap_msr) L4_NOTHROW
 Get a capability register for VMX. More...
 
l4_uint32_t l4_vm_vmx_get_caps_default1 (void const *vcpu_state, unsigned cap_msr) L4_NOTHROW
 Get a default to one capability register for VMX. More...
 
unsigned l4_vm_vmx_field_len (unsigned field) L4_NOTHROW
 Return length in bytes of a VMCS field. More...
 
unsigned l4_vm_vmx_field_order (unsigned field) L4_NOTHROW
 Return length in power of two (bytes) of a VMCS field. More...
 
void l4_vm_vmx_clear (void *vmcs, void *user_vmcs) L4_NOTHROW
 Saves cached state from the kernel VMCS to the user VMCS. More...
 
void l4_vm_vmx_ptr_load (void *vmcs, void *user_vmcs) L4_NOTHROW
 Loads the user_vmcs as the current VMCS. More...
 
l4_uint32_t l4_vm_vmx_get_cr2_index (void const *vmcs) L4_NOTHROW
 Get the VMCS field index of the virtual CR2 register. More...
 
l4_umword_t l4_vm_vmx_read_nat (void *vmcs, unsigned field) L4_NOTHROW
 Read a natural width VMCS field. More...
 
l4_uint16_t l4_vm_vmx_read_16 (void *vmcs, unsigned field) L4_NOTHROW
 Read a 16bit VMCS field. More...
 
l4_uint32_t l4_vm_vmx_read_32 (void *vmcs, unsigned field) L4_NOTHROW
 Read a 32bit VMCS field. More...
 
l4_uint64_t l4_vm_vmx_read_64 (void *vmcs, unsigned field) L4_NOTHROW
 Read a 64bit VMCS field. More...
 
l4_uint64_t l4_vm_vmx_read (void *vmcs, unsigned field) L4_NOTHROW
 Read any VMCS field. More...
 
void l4_vm_vmx_write_nat (void *vmcs, unsigned field, l4_umword_t val) L4_NOTHROW
 Write to a natural width VMCS field. More...
 
void l4_vm_vmx_write_16 (void *vmcs, unsigned field, l4_uint16_t val) L4_NOTHROW
 Write to a 16bit VMCS field. More...
 
void l4_vm_vmx_write_32 (void *vmcs, unsigned field, l4_uint32_t val) L4_NOTHROW
 Write to a 32bit VMCS field. More...
 
void l4_vm_vmx_write_64 (void *vmcs, unsigned field, l4_uint64_t val) L4_NOTHROW
 Write to a 64bit VMCS field. More...
 
void l4_vm_vmx_write (void *vmcs, unsigned field, l4_uint64_t val) L4_NOTHROW
 Write to an arbitrary VMCS field. More...
 

Detailed Description

Virtual machine API for VMX.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Additional (virtual) VMCS fields.

The VMCS offsets defined here are actually not in the hardware VMCS. However our VMMs run in user mode and need to have access to certain registers available in kernel mode only. So we put them into our version of the VMCS.

Enumerator
L4_VM_VMX_VMCS_CR2 

VMCS offset for CR2.

Note
You usually need to check this value against the value you get from l4_vm_vmx_get_cr2_index() to make sure you are running on a compatible kernel.
L4_VM_VMX_VMCS_XCR0 

VMCS offset of extended control register XCR0.

L4_VM_VMX_VMCS_MSR_SYSCALL_MASK 

VMCS offset of system call flag mask MSR.

L4_VM_VMX_VMCS_MSR_LSTAR 

VMCS offset of IA32e mode system call target address MSR.

L4_VM_VMX_VMCS_MSR_CSTAR 

VMCS offset of IA32 mode system call target address MSR.

L4_VM_VMX_VMCS_MSR_TSC_AUX 

VMCS offset of auxiliary TSC signature MSR.

L4_VM_VMX_VMCS_MSR_STAR 

VMCS offset of system call target address MSR.

L4_VM_VMX_VMCS_MSR_KERNEL_GS_BASE 

VMCS offset of GS base address swap target MSR.

Definition at line 105 of file __vm-vmx.h.

◆ L4_vm_vmx_caps_regs

Exported VMX capability registers.

Enumerator
L4_VM_VMX_BASIC_REG 

Basic VMX capabilities.

L4_VM_VMX_TRUE_PINBASED_CTLS_REG 

True pin-based control caps.

L4_VM_VMX_TRUE_PROCBASED_CTLS_REG 

True processor based control caps.

L4_VM_VMX_TRUE_EXIT_CTLS_REG 

True exit control caps.

L4_VM_VMX_TRUE_ENTRY_CTLS_REG 

True entry control caps.

L4_VM_VMX_MISC_REG 

Misc caps.

L4_VM_VMX_CR0_FIXED0_REG 

Fixed to 0 bits of CR0.

L4_VM_VMX_CR0_FIXED1_REG 

Fixed to 1 bits of CR0.

L4_VM_VMX_CR4_FIXED0_REG 

Fixed to 0 bits of CR4.

L4_VM_VMX_CR4_FIXED1_REG 

Fixed to 1 bits of CR4.

L4_VM_VMX_VMCS_ENUM_REG 

VMCS enumeration info.

L4_VM_VMX_PROCBASED_CTLS2_REG 

Processor based control 2 caps.

L4_VM_VMX_EPT_VPID_CAP_REG 

EPT and VPID caps.

L4_VM_VMX_NUM_CAPS_REGS 

Total number of VMX capability registers.

Definition at line 39 of file __vm-vmx.h.

◆ L4_vm_vmx_dfl1_regs

Exported VMX capability registers (default to 1 bits).

Enumerator
L4_VM_VMX_PINBASED_CTLS_DFL1_REG 

Default 1 bits in pin-based controls.

L4_VM_VMX_PROCBASED_CTLS_DFL1_REG 

Default 1 bits in processor-based controls.

L4_VM_VMX_EXIT_CTLS_DFL1_REG 

Default 1 bits in exit controls.

L4_VM_VMX_ENTRY_CTLS_DFL1_REG 

Default 1 bits in entry controls.

L4_VM_VMX_NUM_DFL1_REGS 

Total number of default on registers.

Definition at line 62 of file __vm-vmx.h.

Function Documentation

◆ l4_vm_vmx_clear()

void l4_vm_vmx_clear ( void *  vmcs,
void *  user_vmcs 
)
inline

Saves cached state from the kernel VMCS to the user VMCS.

Parameters
vmcsPointer to the kernel VMCS.
user_vmcsPointer to the user VMCS.

This function is comparable to VMX vmclear.

Definition at line 433 of file __vm-vmx.h.

Referenced by l4_vm_vmx_ptr_load().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_field_len()

unsigned l4_vm_vmx_field_len ( unsigned  field)
inline

Return length in bytes of a VMCS field.

Parameters
fieldField number.
Returns
Width of field in bytes.

Definition at line 357 of file __vm-vmx.h.

References L4_NOTHROW, and l4_vm_vmx_field_order().

+ Here is the call graph for this function:

◆ l4_vm_vmx_field_order()

unsigned l4_vm_vmx_field_order ( unsigned  field)
inline

Return length in power of two (bytes) of a VMCS field.

Parameters
fieldField number.
Returns
Width of field in power of two (bytes).

Definition at line 342 of file __vm-vmx.h.

Referenced by l4_vm_vmx_field_len().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_get_caps()

l4_uint64_t l4_vm_vmx_get_caps ( void const *  vcpu_state,
unsigned  cap_msr 
)
inline

Get a capability register for VMX.

Parameters
vcpu_statePointer to the VCPU state of the VCPU.
cap_msrCaps register index (see L4_vm_vmx_caps_regs).
Returns
The value of the capability register.

Definition at line 529 of file __vm-vmx.h.

References L4_VCPU_OFFSET_EXT_INFOS.

◆ l4_vm_vmx_get_caps_default1()

l4_uint32_t l4_vm_vmx_get_caps_default1 ( void const *  vcpu_state,
unsigned  cap_msr 
)
inline

Get a default to one capability register for VMX.

Parameters
vcpu_statePointer to the VCPU state of the VCPU.
cap_msrDefault 1 caps register index (see L4_vm_vmx_dfl1_regs).
Returns
The value of the capability register.

Definition at line 537 of file __vm-vmx.h.

References L4_VCPU_OFFSET_EXT_INFOS, L4_VM_VMX_NUM_CAPS_REGS, and L4_VM_VMX_PINBASED_CTLS_DFL1_REG.

◆ l4_vm_vmx_get_cr2_index()

l4_uint32_t l4_vm_vmx_get_cr2_index ( void const *  vmcs)
inline

Get the VMCS field index of the virtual CR2 register.

Parameters
vmcsPointer to the software VMCS.
Returns
The field index used for the virtual CR2 register as used by the current Fiasco.OC interface.

The CR2 register is actually not in the hardware VMCS, however our VMMs run in user mode and need to have access to this register so we put it into our software version of the VMCS.

See also
L4_VM_VMX_VMCS_CR2

Definition at line 545 of file __vm-vmx.h.

◆ l4_vm_vmx_ptr_load()

void l4_vm_vmx_ptr_load ( void *  vmcs,
void *  user_vmcs 
)
inline

Loads the user_vmcs as the current VMCS.

Parameters
vmcsPointer to the kernel VMCS.
user_vmcsPointer to the user VMCS.

This function is comparable to VMX vmptrld.

Definition at line 445 of file __vm-vmx.h.

References l4_vm_vmx_clear().

+ Here is the call graph for this function:

◆ l4_vm_vmx_read()

l4_uint64_t l4_vm_vmx_read ( void *  vmcs,
unsigned  field 
)
inline

Read any VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
Returns
The value of the VMCS field with the given index.

Definition at line 481 of file __vm-vmx.h.

References l4_vm_vmx_read_16(), l4_vm_vmx_read_32(), l4_vm_vmx_read_64(), and l4_vm_vmx_read_nat().

+ Here is the call graph for this function:

◆ l4_vm_vmx_read_16()

l4_uint16_t l4_vm_vmx_read_16 ( void *  vmcs,
unsigned  field 
)
inline

Read a 16bit VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
Returns
The value of the VMCS field with the given index.

Definition at line 466 of file __vm-vmx.h.

Referenced by l4_vm_vmx_read().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_read_32()

l4_uint32_t l4_vm_vmx_read_32 ( void *  vmcs,
unsigned  field 
)
inline

Read a 32bit VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
Returns
The value of the VMCS field with the given index.

Definition at line 471 of file __vm-vmx.h.

Referenced by l4_vm_vmx_read().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_read_64()

l4_uint64_t l4_vm_vmx_read_64 ( void *  vmcs,
unsigned  field 
)
inline

Read a 64bit VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
Returns
The value of the VMCS field with the given index.

Definition at line 476 of file __vm-vmx.h.

Referenced by l4_vm_vmx_read().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_read_nat()

l4_umword_t l4_vm_vmx_read_nat ( void *  vmcs,
unsigned  field 
)
inline

Read a natural width VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
Returns
The value of the VMCS field with the given index.

Definition at line 461 of file __vm-vmx.h.

Referenced by l4_vm_vmx_read().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_write()

void l4_vm_vmx_write ( void *  vmcs,
unsigned  field,
l4_uint64_t  val 
)
inline

Write to an arbitrary VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
valThe value that shall be written to the given field.

Definition at line 516 of file __vm-vmx.h.

References l4_vm_vmx_write_16(), l4_vm_vmx_write_32(), l4_vm_vmx_write_64(), and l4_vm_vmx_write_nat().

+ Here is the call graph for this function:

◆ l4_vm_vmx_write_16()

void l4_vm_vmx_write_16 ( void *  vmcs,
unsigned  field,
l4_uint16_t  val 
)
inline

Write to a 16bit VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
valThe value that shall be written to the given field.

Definition at line 500 of file __vm-vmx.h.

Referenced by l4_vm_vmx_write().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_write_32()

void l4_vm_vmx_write_32 ( void *  vmcs,
unsigned  field,
l4_uint32_t  val 
)
inline

Write to a 32bit VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
valThe value that shall be written to the given field.

Definition at line 505 of file __vm-vmx.h.

Referenced by l4_vm_vmx_write().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_write_64()

void l4_vm_vmx_write_64 ( void *  vmcs,
unsigned  field,
l4_uint64_t  val 
)
inline

Write to a 64bit VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
valThe value that shall be written to the given field.

Definition at line 510 of file __vm-vmx.h.

Referenced by l4_vm_vmx_write().

+ Here is the caller graph for this function:

◆ l4_vm_vmx_write_nat()

void l4_vm_vmx_write_nat ( void *  vmcs,
unsigned  field,
l4_umword_t  val 
)
inline

Write to a natural width VMCS field.

Parameters
vmcsPointer to the software VMCS.
fieldThe VMCS field index as used on VMX hardware.
valThe value that shall be written to the given field.

Definition at line 495 of file __vm-vmx.h.

Referenced by l4_vm_vmx_write().

+ Here is the caller graph for this function: