MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_mem_allocated

Function vm_mem_allocated

freebsd/amd64/vmm/vmm.c:644–667  ·  view source on GitHub ↗

* Return 'true' if 'gpa' is allocated in the guest address space. * * This function is called in the context of a running vcpu which acts as * an implicit lock on 'vm->mem_maps[]'. */

Source from the content-addressed store, hash-verified

642 * an implicit lock on 'vm->mem_maps[]'.
643 */
644bool
645vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa)
646{
647 struct mem_map *mm;
648 int i;
649
650#ifdef INVARIANTS
651 int hostcpu, state;
652 state = vcpu_get_state(vm, vcpuid, &hostcpu);
653 KASSERT(state == VCPU_RUNNING && hostcpu == curcpu,
654 ("%s: invalid vcpu state %d/%d", __func__, state, hostcpu));
655#endif
656
657 for (i = 0; i < VM_MAX_MEMMAPS; i++) {
658 mm = &vm->mem_maps[i];
659 if (mm->len != 0 && gpa >= mm->gpa && gpa < mm->gpa + mm->len)
660 return (true); /* 'gpa' is sysmem or devmem */
661 }
662
663 if (ppt_is_mmio(vm, gpa))
664 return (true); /* 'gpa' is pci passthru mmio */
665
666 return (false);
667}
668
669int
670vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem)

Callers 2

svm_vmexitFunction · 0.85
vmx_exit_processFunction · 0.85

Calls 2

vcpu_get_stateFunction · 0.85
ppt_is_mmioFunction · 0.85

Tested by

no test coverage detected