Lines Matching full:vm

18 void virt_pgd_alloc(struct kvm_vm *vm, uint32_t memslot)  in virt_pgd_alloc()  argument
22 TEST_ASSERT(vm->page_size == 4096, "Unsupported page size: 0x%x", in virt_pgd_alloc()
23 vm->page_size); in virt_pgd_alloc()
25 if (vm->pgd_created) in virt_pgd_alloc()
28 paddr = vm_phy_pages_alloc(vm, PAGES_PER_REGION, in virt_pgd_alloc()
30 memset(addr_gpa2hva(vm, paddr), 0xff, PAGES_PER_REGION * vm->page_size); in virt_pgd_alloc()
32 vm->pgd = paddr; in virt_pgd_alloc()
33 vm->pgd_created = true; in virt_pgd_alloc()
41 static uint64_t virt_alloc_region(struct kvm_vm *vm, int ri, uint32_t memslot) in virt_alloc_region() argument
45 taddr = vm_phy_pages_alloc(vm, ri < 4 ? PAGES_PER_REGION : 1, in virt_alloc_region()
47 memset(addr_gpa2hva(vm, taddr), 0xff, PAGES_PER_REGION * vm->page_size); in virt_alloc_region()
54 void virt_pg_map(struct kvm_vm *vm, uint64_t gva, uint64_t gpa, in virt_pg_map() argument
60 TEST_ASSERT((gva % vm->page_size) == 0, in virt_pg_map()
62 " vaddr: 0x%lx vm->page_size: 0x%x", in virt_pg_map()
63 gva, vm->page_size); in virt_pg_map()
64 TEST_ASSERT(sparsebit_is_set(vm->vpages_valid, in virt_pg_map()
65 (gva >> vm->page_shift)), in virt_pg_map()
68 TEST_ASSERT((gpa % vm->page_size) == 0, in virt_pg_map()
70 " paddr: 0x%lx vm->page_size: 0x%x", in virt_pg_map()
71 gva, vm->page_size); in virt_pg_map()
72 TEST_ASSERT((gpa >> vm->page_shift) <= vm->max_gfn, in virt_pg_map()
74 " paddr: 0x%lx vm->max_gfn: 0x%lx vm->page_size: 0x%x", in virt_pg_map()
75 gva, vm->max_gfn, vm->page_size); in virt_pg_map()
78 entry = addr_gpa2hva(vm, vm->pgd); in virt_pg_map()
82 entry[idx] = virt_alloc_region(vm, ri, memslot); in virt_pg_map()
83 entry = addr_gpa2hva(vm, entry[idx] & REGION_ENTRY_ORIGIN); in virt_pg_map()
94 vm_paddr_t addr_gva2gpa(struct kvm_vm *vm, vm_vaddr_t gva) in addr_gva2gpa() argument
99 TEST_ASSERT(vm->page_size == 4096, "Unsupported page size: 0x%x", in addr_gva2gpa()
100 vm->page_size); in addr_gva2gpa()
102 entry = addr_gpa2hva(vm, vm->pgd); in addr_gva2gpa()
106 "No region mapping for vm virtual address 0x%lx", in addr_gva2gpa()
108 entry = addr_gpa2hva(vm, entry[idx] & REGION_ENTRY_ORIGIN); in addr_gva2gpa()
114 "No page mapping for vm virtual address 0x%lx", gva); in addr_gva2gpa()
119 static void virt_dump_ptes(FILE *stream, struct kvm_vm *vm, uint8_t indent, in virt_dump_ptes() argument
125 pte = addr_gpa2hva(vm, ptea); in virt_dump_ptes()
133 static void virt_dump_region(FILE *stream, struct kvm_vm *vm, uint8_t indent, in virt_dump_region() argument
139 entry = addr_gpa2hva(vm, addr); in virt_dump_region()
146 virt_dump_region(stream, vm, indent + 2, in virt_dump_region()
149 virt_dump_ptes(stream, vm, indent + 2, in virt_dump_region()
155 void virt_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent) in virt_dump() argument
157 if (!vm->pgd_created) in virt_dump()
160 virt_dump_region(stream, vm, indent, vm->pgd); in virt_dump()
172 struct kvm_vm *vm; in vm_create_default() local
174 vm = vm_create(VM_MODE_DEFAULT, in vm_create_default()
177 kvm_vm_elf_load(vm, program_invocation_name, 0, 0); in vm_create_default()
178 vm_vcpu_add_default(vm, vcpuid, guest_code); in vm_create_default()
180 return vm; in vm_create_default()
183 void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code) in vm_vcpu_add_default() argument
191 TEST_ASSERT(vm->page_size == 4096, "Unsupported page size: 0x%x", in vm_vcpu_add_default()
192 vm->page_size); in vm_vcpu_add_default()
194 stack_vaddr = vm_vaddr_alloc(vm, stack_size, in vm_vcpu_add_default()
197 vm_vcpu_add(vm, vcpuid); in vm_vcpu_add_default()
200 vcpu_regs_get(vm, vcpuid, &regs); in vm_vcpu_add_default()
202 vcpu_regs_set(vm, vcpuid, &regs); in vm_vcpu_add_default()
204 vcpu_sregs_get(vm, vcpuid, &sregs); in vm_vcpu_add_default()
206 sregs.crs[1] = vm->pgd | 0xf; /* Primary region table */ in vm_vcpu_add_default()
207 vcpu_sregs_set(vm, vcpuid, &sregs); in vm_vcpu_add_default()
209 run = vcpu_state(vm, vcpuid); in vm_vcpu_add_default()
214 void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...) in vcpu_args_set() argument
225 vcpu_regs_get(vm, vcpuid, &regs); in vcpu_args_set()
230 vcpu_regs_set(vm, vcpuid, &regs); in vcpu_args_set()
234 void vcpu_dump(FILE *stream, struct kvm_vm *vm, uint32_t vcpuid, uint8_t indent) in vcpu_dump() argument
236 struct vcpu *vcpu = vcpu_find(vm, vcpuid); in vcpu_dump()
245 void assert_on_unhandled_exception(struct kvm_vm *vm, uint32_t vcpuid) in assert_on_unhandled_exception() argument