linux/tools/testing/selftests/kvm/lib/vmx.c
/* Allocate memory regions for nested VMX tests.
 *
 * Input Args:
 *   vm - The VM to allocate guest-virtual addresses in.
 *
 * Output Args:
 *   p_vmx_gva - The guest virtual address for the struct vmx_pages.
 *
 * Return:
 *   Pointer to structure with the addresses of the VMX areas.
 */
Allocate memory regions for nested VMX tests.
Input Args:
vm - The VM to allocate guest-virtual addresses in.

Output Args:
p_vmx_gva - The guest virtual address for the struct vmx_pages.

Pointer to structure with the addresses of the VMX areas.
Allocate memory regions for nested VMX tests . Input Args : vm - The VM to allocate guest - virtual addresses in . Output Args : p_vmx_gva - The guest virtual address for the struct vmx_pages . Pointer to structure with the addresses of the VMX areas .
struct vmx_pages *
vcpu_alloc_vmx(struct kvm_vm *vm, vm_vaddr_t *p_vmx_gva)
{
	vm_vaddr_t vmx_gva = vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	struct vmx_pages *vmx = addr_gva2hva(vm, vmx_gva);
	vmx->vmxon = (void *)vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	vmx->vmxon_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmxon);
	vmx->vmxon_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmxon);
	vmx->vmcs = (void *)vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	vmx->vmcs_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmcs);
	vmx->vmcs_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmcs);
	vmx->msr = (void *)vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	vmx->msr_hva = addr_gva2hva(vm, (uintptr_t)vmx->msr);
	vmx->msr_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->msr);
	memset(vmx->msr_hva, 0, getpagesize());
	vmx->shadow_vmcs = (void *)vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	vmx->shadow_vmcs_hva = addr_gva2hva(vm, (uintptr_t)vmx->shadow_vmcs);
	vmx->shadow_vmcs_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->shadow_vmcs);
	vmx->vmread = (void *)vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	vmx->vmread_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmread);
	vmx->vmread_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmread);
	memset(vmx->vmread_hva, 0, getpagesize());
	vmx->vmwrite = (void *)vm_vaddr_alloc(vm, getpagesize(), 0x10000, 0, 0);
	vmx->vmwrite_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmwrite);
	vmx->vmwrite_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmwrite);
	memset(vmx->vmwrite_hva, 0, getpagesize());
	*p_vmx_gva = vmx_gva;
	return vmx;
}
struct vmx_pages * vcpu_alloc_vmx ( struct kvm_vm * vm , vm_vaddr_t * p_vmx_gva ) { vm_vaddr_t vmx_gva = vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; struct vmx_pages * vmx = addr_gva2hva ( vm , vmx_gva ) ; vmx -> vmxon = ( void * ) vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; vmx -> vmxon_hva = addr_gva2hva ( vm , ( uintptr_t ) vmx -> vmxon ) ; vmx -> vmxon_gpa = addr_gva2gpa ( vm , ( uintptr_t ) vmx -> vmxon ) ; vmx -> vmcs = ( void * ) vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; vmx -> vmcs_hva = addr_gva2hva ( vm , ( uintptr_t ) vmx -> vmcs ) ; vmx -> vmcs_gpa = addr_gva2gpa ( vm , ( uintptr_t ) vmx -> vmcs ) ; vmx -> msr = ( void * ) vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; vmx -> msr_hva = addr_gva2hva ( vm , ( uintptr_t ) vmx -> msr ) ; vmx -> msr_gpa = addr_gva2gpa ( vm , ( uintptr_t ) vmx -> msr ) ; memset ( vmx -> msr_hva , 0 , getpagesize ( ) ) ; vmx -> shadow_vmcs = ( void * ) vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; vmx -> shadow_vmcs_hva = addr_gva2hva ( vm , ( uintptr_t ) vmx -> shadow_vmcs ) ; vmx -> shadow_vmcs_gpa = addr_gva2gpa ( vm , ( uintptr_t ) vmx -> shadow_vmcs ) ; vmx -> vmread = ( void * ) vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; vmx -> vmread_hva = addr_gva2hva ( vm , ( uintptr_t ) vmx -> vmread ) ; vmx -> vmread_gpa = addr_gva2gpa ( vm , ( uintptr_t ) vmx -> vmread ) ; memset ( vmx -> vmread_hva , 0 , getpagesize ( ) ) ; vmx -> vmwrite = ( void * ) vm_vaddr_alloc ( vm , getpagesize ( ) , 0x10000 , 0 , 0 ) ; vmx -> vmwrite_hva = addr_gva2hva ( vm , ( uintptr_t ) vmx -> vmwrite ) ; vmx -> vmwrite_gpa = addr_gva2gpa ( vm , ( uintptr_t ) vmx -> vmwrite ) ; memset ( vmx -> vmwrite_hva , 0 , getpagesize ( ) ) ; * p_vmx_gva = vmx_gva ; return vmx ; }
Allocate memory regions for nested VMX tests.
Allocate memory regions for nested VMX tests .
/* Setup of a region of guest memory for the vmxon region. */ /* Setup of a region of guest memory for a vmcs. */ /* Setup of a region of guest memory for the MSR bitmap. */ /* Setup of a region of guest memory for the shadow VMCS. */ /* Setup of a region of guest memory for the VMREAD and VMWRITE bitmaps. */