117 L4_VM_VMX_VMCS_NAT_ARG0 = 0x6840,
119 L4_VM_VMX_VMCS_NAT_ARG1 = 0x6842,
121 L4_VM_VMX_VMCS_NAT_ARG2 = 0x6844,
123 L4_VM_VMX_VMCS_NAT_ARG3 = 0x6846,
197enum L4_vm_vmx_vmcs_sizes
199 L4_VM_VMX_VMCS_SIZE_VALUES = 2560,
200 L4_VM_VMX_VMCS_SIZE_DIRTY_BITMAP = 320,
246#if L4_MWORD_BITS == 32
248#elif L4_MWORD_BITS == 64
251 #error Unsupported machine word size.
257 l4_uint8_t values[L4_VM_VMX_VMCS_SIZE_VALUES];
258 l4_uint8_t dirty_bitmap[L4_VM_VMX_VMCS_SIZE_DIRTY_BITMAP];
300l4_vm_vmx_field_ptr(
void *vmcs,
unsigned field)
L4_NOTHROW;
520 unsigned size = (field >> 13) & 0x03U;
542l4_vm_vmx_field_offset(
void const *vmcs,
unsigned field)
L4_NOTHROW
546 unsigned index = field & 0x3feU;
547 unsigned size = (field >> 13) & 0x03U;
548 unsigned group = (field >> 10) & 0x03U;
550 unsigned shifted_index = index << state->offset_table.index_shifts[size];
552 if (shifted_index >= (
unsigned)state->offset_table.limits[size][group] * 64)
555 return (
unsigned)state->offset_table.offsets[size][group] * 64
561l4_vm_vmx_field_ptr(
void *vmcs,
unsigned field)
L4_NOTHROW
565 unsigned offset = l4_vm_vmx_field_offset(vmcs, field);
569 return (
void *)(state->values + offset);
579l4_vm_vmx_field_ptr_offset(
void *vmcs,
unsigned field,
unsigned *offset)
L4_NOTHROW
583 *offset = l4_vm_vmx_field_offset(vmcs, field);
587 return (
void *)(state->values + *offset);
597l4_vm_vmx_offset_dirty(
void *vmcs,
unsigned offset)
L4_NOTHROW
601 state->dirty_bitmap[offset / 8] |= 1U << (offset % 8);
613 unsigned base_offset = state->offset_table.base_offset * 64;
614 unsigned size = state->offset_table.size * 64;
616 void *dst = _dst + base_offset;
617 void const *src = _src + base_offset;
618 __builtin_memcpy(dst, src, size);
628 void **current_vmcs_ptr = (
void **)&state->user_data;
629 if (*current_vmcs_ptr != user_vmcs)
633 l4_vm_vmx_copy_values(state, user_state->values, state->values);
636 __builtin_memcpy(user_state->dirty_bitmap, state->dirty_bitmap,
637 L4_VM_VMX_VMCS_SIZE_DIRTY_BITMAP);
639 *current_vmcs_ptr = 0;
649 void **current_vmcs_ptr = (
void **)&state->user_data;
651 if (*current_vmcs_ptr == user_vmcs)
654 if (*current_vmcs_ptr && *current_vmcs_ptr != user_vmcs)
657 *current_vmcs_ptr = user_vmcs;
660 l4_vm_vmx_copy_values(state, state->values, user_state->values);
663 __builtin_memcpy(state->dirty_bitmap, user_state->dirty_bitmap,
664 L4_VM_VMX_VMCS_SIZE_DIRTY_BITMAP);
715 unsigned size = (field >> 13) & 0x03U;
736 if ((ptr) && (*ptr != val))
739 l4_vm_vmx_offset_dirty(vmcs, offset);
751 if ((ptr) && (*ptr != val))
754 l4_vm_vmx_offset_dirty(vmcs, offset);
766 if ((ptr) && (*ptr != val))
769 l4_vm_vmx_offset_dirty(vmcs, offset);
781 if ((ptr) && (*ptr != val))
784 l4_vm_vmx_offset_dirty(vmcs, offset);
792 unsigned size = (field >> 13) & 0x03U;
808 return caps[cap_msr & 0x0fU];
824 return state->cr2_index;
832 state->vmcs = vmcs_cap;
unsigned long l4_umword_t
Unsigned machine word.
unsigned char l4_uint8_t
Unsigned 8bit value.
unsigned int l4_uint32_t
Unsigned 32bit value.
unsigned short int l4_uint16_t
Unsigned 16bit value.
unsigned long long l4_uint64_t
Unsigned 64bit value.
unsigned long l4_cap_idx_t
Capability selector type.
@ L4_CAP_MASK
Mask to get only the relevant bits of an l4_cap_idx_t.
@ L4_VCPU_OFFSET_EXT_INFOS
Offset where extended infos begin.
void l4_vm_vmx_write_nat(void *vmcs, unsigned field, l4_umword_t val) L4_NOTHROW
Write to a natural-width software VMCS field.
void l4_vm_vmx_ptr_load(void *vmcs, void *user_vmcs) L4_NOTHROW
Loads the user_vmcs as the current software VMCS.
l4_uint16_t l4_vm_vmx_read_16(void *vmcs, unsigned field) L4_NOTHROW
Read a 16-bit software VMCS field.
L4_vm_vmx_sw_fields
Additional (virtual) VMCS fields.
unsigned l4_vm_vmx_field_order(unsigned field) L4_NOTHROW
Return length in power of two (bytes) of a VMCS field.
void l4_vm_vmx_write_32(void *vmcs, unsigned field, l4_uint32_t val) L4_NOTHROW
Write to a 32-bit software VMCS field.
l4_uint32_t l4_vm_vmx_get_cr2_index(void const *vmcs) L4_NOTHROW
Get the software VMCS field index of the virtual CR2 register.
void l4_vm_vmx_clear(void *vmcs, void *user_vmcs) L4_NOTHROW
Saves cached state from the kernel software VMCS to the user software VMCS.
l4_uint64_t l4_vm_vmx_read(void *vmcs, unsigned field) L4_NOTHROW
Read any software VMCS field.
l4_uint32_t l4_vm_vmx_read_32(void *vmcs, unsigned field) L4_NOTHROW
Read a 32-bit software VMCS field.
l4_cap_idx_t l4_vm_vmx_get_hw_vmcs(void *vmcs) L4_NOTHROW
Get the hardware VMCS object capability associated with the software VMCS.
unsigned l4_vm_vmx_field_len(unsigned field) L4_NOTHROW
Return length in bytes of a VMCS field.
L4_vm_vmx_caps_regs
Exported VMX capability registers.
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.
void l4_vm_vmx_write(void *vmcs, unsigned field, l4_uint64_t val) L4_NOTHROW
Write to an arbitrary software VMCS field.
void l4_vm_vmx_write_64(void *vmcs, unsigned field, l4_uint64_t val) L4_NOTHROW
Write to a 64-bit software VMCS field.
l4_umword_t l4_vm_vmx_read_nat(void *vmcs, unsigned field) L4_NOTHROW
Read a natural-width software VMCS field.
l4_uint64_t l4_vm_vmx_read_64(void *vmcs, unsigned field) L4_NOTHROW
Read a 64-bit software VMCS field.
L4_vm_vmx_dfl1_regs
Exported VMX capability registers (default to 1 bits).
l4_uint64_t l4_vm_vmx_get_caps(void const *vcpu_state, unsigned cap_msr) L4_NOTHROW
Get a capability register for VMX.
void l4_vm_vmx_write_16(void *vmcs, unsigned field, l4_uint16_t val) L4_NOTHROW
Write to a 16-bit software VMCS field.
void l4_vm_vmx_set_hw_vmcs(void *vmcs, l4_cap_idx_t vmcs_cap) L4_NOTHROW
Associate the software VMCS with a hardware VMCS object capability.
@ L4_VM_VMX_VMCS_MSR_LSTAR
VMCS offset of IA32e mode system call target address MSR.
@ L4_VM_VMX_VMCS_MSR_STAR
VMCS offset of system call target address MSR.
@ L4_VM_VMX_VMCS_CR2
VMCS offset for CR2.
@ L4_VM_VMX_VMCS_XCR0
VMCS offset of extended control register XCR0.
@ L4_VM_VMX_VMCS_MSR_TSC_AUX
VMCS offset of auxiliary TSC signature MSR.
@ L4_VM_VMX_VMCS_MSR_KERNEL_GS_BASE
VMCS offset of GS base address swap target MSR.
@ L4_VM_VMX_VMCS_MSR_SYSCALL_MASK
VMCS offset of system call flag mask MSR.
@ L4_VM_VMX_VMCS_MSR_CSTAR
VMCS offset of IA32 mode system call target address MSR.
@ L4_VM_VMX_TRUE_PROCBASED_CTLS_REG
True processor based control caps.
@ L4_VM_VMX_MISC_REG
Misc caps.
@ 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_CR4_FIXED1_REG
Fixed to 1 bits of CR4.
@ L4_VM_VMX_NUM_CAPS_REGS
Total number of VMX capability registers.
@ L4_VM_VMX_CR4_FIXED0_REG
Fixed to 0 bits of CR4.
@ L4_VM_VMX_TRUE_ENTRY_CTLS_REG
True entry control caps.
@ L4_VM_VMX_NESTED_REVISION
Nested VMCS revision.
@ L4_VM_VMX_CR0_FIXED1_REG
Fixed to 1 bits of CR0.
@ L4_VM_VMX_CR0_FIXED0_REG
Fixed to 0 bits of CR0.
@ L4_VM_VMX_VMCS_ENUM_REG
VMCS enumeration info.
@ L4_VM_VMX_TRUE_EXIT_CTLS_REG
True exit control caps.
@ L4_VM_VMX_TRUE_PINBASED_CTLS_REG
True pin-based control caps.
@ L4_VM_VMX_BASIC_REG
Basic VMX capabilities.
@ L4_VM_VMX_ENTRY_CTLS_DFL1_REG
Default 1 bits in entry controls.
@ L4_VM_VMX_EXIT_CTLS_DFL1_REG
Default 1 bits in exit controls.
@ L4_VM_VMX_PINBASED_CTLS_DFL1_REG
Default 1 bits in pin-based controls.
@ L4_VM_VMX_NUM_DFL1_REGS
Total number of default on registers.
@ L4_VM_VMX_PROCBASED_CTLS_DFL1_REG
Default 1 bits in processor-based controls.
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
#define L4_INLINE
L4 Inline function attribute.
Software VMCS field offset table.