linux/tools/testing/selftests/kvm/lib/vmx.c
/*
 * Initialize the control fields to the most basic settings possible.
 */
Initialize the control fields to the most basic settings possible.
Initialize the control fields to the most basic settings possible .
static inline void init_vmcs_control_fields(struct vmx_pages *vmx)
{
	vmwrite(VIRTUAL_PROCESSOR_ID, 0);
	vmwrite(POSTED_INTR_NV, 0);
	vmwrite(PIN_BASED_VM_EXEC_CONTROL, rdmsr(MSR_IA32_VMX_TRUE_PINBASED_CTLS));
	if (!vmwrite(SECONDARY_VM_EXEC_CONTROL, 0))
		vmwrite(CPU_BASED_VM_EXEC_CONTROL,
			rdmsr(MSR_IA32_VMX_TRUE_PROCBASED_CTLS) | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS);
	else
		vmwrite(CPU_BASED_VM_EXEC_CONTROL, rdmsr(MSR_IA32_VMX_TRUE_PROCBASED_CTLS));
	vmwrite(EXCEPTION_BITMAP, 0);
	vmwrite(PAGE_FAULT_ERROR_CODE_MASK, 0);
	vmwrite(PAGE_FAULT_ERROR_CODE_MATCH, -1); 
	vmwrite(CR3_TARGET_COUNT, 0);
	vmwrite(VM_EXIT_CONTROLS, rdmsr(MSR_IA32_VMX_EXIT_CTLS) |
		VM_EXIT_HOST_ADDR_SPACE_SIZE);	  
	vmwrite(VM_EXIT_MSR_STORE_COUNT, 0);
	vmwrite(VM_EXIT_MSR_LOAD_COUNT, 0);
	vmwrite(VM_ENTRY_CONTROLS, rdmsr(MSR_IA32_VMX_ENTRY_CTLS) |
		VM_ENTRY_IA32E_MODE);		  
	vmwrite(VM_ENTRY_MSR_LOAD_COUNT, 0);
	vmwrite(VM_ENTRY_INTR_INFO_FIELD, 0);
	vmwrite(TPR_THRESHOLD, 0);
	vmwrite(CR0_GUEST_HOST_MASK, 0);
	vmwrite(CR4_GUEST_HOST_MASK, 0);
	vmwrite(CR0_READ_SHADOW, get_cr0());
	vmwrite(CR4_READ_SHADOW, get_cr4());
	vmwrite(MSR_BITMAP, vmx->msr_gpa);
	vmwrite(VMREAD_BITMAP, vmx->vmread_gpa);
	vmwrite(VMWRITE_BITMAP, vmx->vmwrite_gpa);
}
static inline void init_vmcs_control_fields ( struct vmx_pages * vmx ) { vmwrite ( VIRTUAL_PROCESSOR_ID , 0 ) ; vmwrite ( POSTED_INTR_NV , 0 ) ; vmwrite ( PIN_BASED_VM_EXEC_CONTROL , rdmsr ( MSR_IA32_VMX_TRUE_PINBASED_CTLS ) ) ; if ( ! vmwrite ( SECONDARY_VM_EXEC_CONTROL , 0 ) ) vmwrite ( CPU_BASED_VM_EXEC_CONTROL , rdmsr ( MSR_IA32_VMX_TRUE_PROCBASED_CTLS ) | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS ) ; else vmwrite ( CPU_BASED_VM_EXEC_CONTROL , rdmsr ( MSR_IA32_VMX_TRUE_PROCBASED_CTLS ) ) ; vmwrite ( EXCEPTION_BITMAP , 0 ) ; vmwrite ( PAGE_FAULT_ERROR_CODE_MASK , 0 ) ; vmwrite ( PAGE_FAULT_ERROR_CODE_MATCH , -1 ) ; vmwrite ( CR3_TARGET_COUNT , 0 ) ; vmwrite ( VM_EXIT_CONTROLS , rdmsr ( MSR_IA32_VMX_EXIT_CTLS ) | VM_EXIT_HOST_ADDR_SPACE_SIZE ) ; vmwrite ( VM_EXIT_MSR_STORE_COUNT , 0 ) ; vmwrite ( VM_EXIT_MSR_LOAD_COUNT , 0 ) ; vmwrite ( VM_ENTRY_CONTROLS , rdmsr ( MSR_IA32_VMX_ENTRY_CTLS ) | VM_ENTRY_IA32E_MODE ) ; vmwrite ( VM_ENTRY_MSR_LOAD_COUNT , 0 ) ; vmwrite ( VM_ENTRY_INTR_INFO_FIELD , 0 ) ; vmwrite ( TPR_THRESHOLD , 0 ) ; vmwrite ( CR0_GUEST_HOST_MASK , 0 ) ; vmwrite ( CR4_GUEST_HOST_MASK , 0 ) ; vmwrite ( CR0_READ_SHADOW , get_cr0 ( ) ) ; vmwrite ( CR4_READ_SHADOW , get_cr4 ( ) ) ; vmwrite ( MSR_BITMAP , vmx -> msr_gpa ) ; vmwrite ( VMREAD_BITMAP , vmx -> vmread_gpa ) ; vmwrite ( VMWRITE_BITMAP , vmx -> vmwrite_gpa ) ; }
Initialize the control fields to the most basic settings possible.
Initialize the control fields to the most basic settings possible .
/* Never match */ /* 64-bit host */ /* 64-bit guest */