-#define bitfield(x,f) ((x >> f##_BIT) & f##_MASK)
- /* Obtain and decode VMX general capabilities */
- msr_image = rdmsr64(MSR_IA32_VMX_BASIC);
- specs->vmcs_id = (uint32_t)(msr_image & VMX_VCR_VMCS_REV_ID);
- specs->vmcs_mem_type = bitfield(msr_image, VMX_VCR_VMCS_MEM_TYPE) != 0;
- specs->vmcs_size = bitfield(msr_image, VMX_VCR_VMCS_SIZE);
-
- /* Obtain allowed settings for pin-based execution controls */
- msr_image = rdmsr64(MSR_IA32_VMXPINBASED_CTLS);
- specs->pin_exctls_0 = (uint32_t)(msr_image & 0xFFFFFFFF);
- specs->pin_exctls_1 = (uint32_t)(msr_image >> 32);
-
- /* Obtain allowed settings for processor-based execution controls */
- msr_image = rdmsr64(MSR_IA32_PROCBASED_CTLS);
- specs->proc_exctls_0 = (uint32_t)(msr_image & 0xFFFFFFFF);
- specs->proc_exctls_1 = (uint32_t)(msr_image >> 32);
-
- /* Obtain allowed settings for VM-exit controls */
- msr_image = rdmsr64(MSR_IA32_VMX_EXIT_CTLS);
- specs->exit_ctls_0 = (uint32_t)(msr_image & 0xFFFFFFFF);
- specs->exit_ctls_1 = (uint32_t)(msr_image >> 32);
-
- /* Obtain allowed settings for VM-entry controls */
- msr_image = rdmsr64(MSR_IA32_VMX_ENTRY_CTLS);
- specs->enter_ctls_0 = (uint32_t)(msr_image & 0xFFFFFFFF);
- specs->enter_ctls_0 = (uint32_t)(msr_image >> 32);
-
- /* Obtain and decode miscellaneous capabilities */
- msr_image = rdmsr64(MSR_IA32_VMX_MISC);
- specs->act_halt = bitfield(msr_image, VMX_VCR_ACT_HLT) != 0;
- specs->act_shutdown = bitfield(msr_image, VMX_VCR_ACT_SHUTDOWN) != 0;
- specs->act_SIPI = bitfield(msr_image, VMX_VCR_ACT_SIPI) != 0;
- specs->act_CSTATE = bitfield(msr_image, VMX_VCR_ACT_CSTATE) != 0;
- specs->cr3_targs = bitfield(msr_image, VMX_VCR_CR3_TARGS);
- specs->max_msrs = (uint32_t)(512 * (1 + bitfield(msr_image, VMX_VCR_MAX_MSRS)));
- specs->mseg_id = (uint32_t)bitfield(msr_image, VMX_VCR_MSEG_ID);
-