Lines Matching full:vm
13 void virt_arch_pgd_alloc(struct kvm_vm *vm) in virt_arch_pgd_alloc() argument
17 TEST_ASSERT(vm->page_size == 4096, "Unsupported page size: 0x%x", in virt_arch_pgd_alloc()
18 vm->page_size); in virt_arch_pgd_alloc()
20 if (vm->pgd_created) in virt_arch_pgd_alloc()
23 paddr = vm_phy_pages_alloc(vm, PAGES_PER_REGION, in virt_arch_pgd_alloc()
25 memset(addr_gpa2hva(vm, paddr), 0xff, PAGES_PER_REGION * vm->page_size); in virt_arch_pgd_alloc()
27 vm->pgd = paddr; in virt_arch_pgd_alloc()
28 vm->pgd_created = true; in virt_arch_pgd_alloc()
36 static uint64_t virt_alloc_region(struct kvm_vm *vm, int ri) in virt_alloc_region() argument
40 taddr = vm_phy_pages_alloc(vm, ri < 4 ? PAGES_PER_REGION : 1, in virt_alloc_region()
42 memset(addr_gpa2hva(vm, taddr), 0xff, PAGES_PER_REGION * vm->page_size); in virt_alloc_region()
49 void virt_arch_pg_map(struct kvm_vm *vm, uint64_t gva, uint64_t gpa) in virt_arch_pg_map() argument
54 TEST_ASSERT((gva % vm->page_size) == 0, in virt_arch_pg_map()
56 " vaddr: 0x%lx vm->page_size: 0x%x", in virt_arch_pg_map()
57 gva, vm->page_size); in virt_arch_pg_map()
58 TEST_ASSERT(sparsebit_is_set(vm->vpages_valid, in virt_arch_pg_map()
59 (gva >> vm->page_shift)), in virt_arch_pg_map()
62 TEST_ASSERT((gpa % vm->page_size) == 0, in virt_arch_pg_map()
64 " paddr: 0x%lx vm->page_size: 0x%x", in virt_arch_pg_map()
65 gva, vm->page_size); in virt_arch_pg_map()
66 TEST_ASSERT((gpa >> vm->page_shift) <= vm->max_gfn, in virt_arch_pg_map()
68 " paddr: 0x%lx vm->max_gfn: 0x%lx vm->page_size: 0x%x", in virt_arch_pg_map()
69 gva, vm->max_gfn, vm->page_size); in virt_arch_pg_map()
72 entry = addr_gpa2hva(vm, vm->pgd); in virt_arch_pg_map()
76 entry[idx] = virt_alloc_region(vm, ri); in virt_arch_pg_map()
77 entry = addr_gpa2hva(vm, entry[idx] & REGION_ENTRY_ORIGIN); in virt_arch_pg_map()
88 vm_paddr_t addr_arch_gva2gpa(struct kvm_vm *vm, vm_vaddr_t gva) in addr_arch_gva2gpa() argument
93 TEST_ASSERT(vm->page_size == 4096, "Unsupported page size: 0x%x", in addr_arch_gva2gpa()
94 vm->page_size); in addr_arch_gva2gpa()
96 entry = addr_gpa2hva(vm, vm->pgd); in addr_arch_gva2gpa()
100 "No region mapping for vm virtual address 0x%lx", in addr_arch_gva2gpa()
102 entry = addr_gpa2hva(vm, entry[idx] & REGION_ENTRY_ORIGIN); in addr_arch_gva2gpa()
108 "No page mapping for vm virtual address 0x%lx", gva); in addr_arch_gva2gpa()
113 static void virt_dump_ptes(FILE *stream, struct kvm_vm *vm, uint8_t indent, in virt_dump_ptes() argument
119 pte = addr_gpa2hva(vm, ptea); in virt_dump_ptes()
127 static void virt_dump_region(FILE *stream, struct kvm_vm *vm, uint8_t indent, in virt_dump_region() argument
133 entry = addr_gpa2hva(vm, addr); in virt_dump_region()
140 virt_dump_region(stream, vm, indent + 2, in virt_dump_region()
143 virt_dump_ptes(stream, vm, indent + 2, in virt_dump_region()
149 void virt_arch_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent) in virt_arch_dump() argument
151 if (!vm->pgd_created) in virt_arch_dump()
154 virt_dump_region(stream, vm, indent, vm->pgd); in virt_arch_dump()
157 struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id, in vm_arch_vcpu_add() argument
167 TEST_ASSERT(vm->page_size == 4096, "Unsupported page size: 0x%x", in vm_arch_vcpu_add()
168 vm->page_size); in vm_arch_vcpu_add()
170 stack_vaddr = vm_vaddr_alloc(vm, stack_size, in vm_arch_vcpu_add()
173 vcpu = __vm_vcpu_add(vm, vcpu_id); in vm_arch_vcpu_add()
182 sregs.crs[1] = vm->pgd | 0xf; /* Primary region table */ in vm_arch_vcpu_add()