diff options
author | 2015-12-01 10:18:35 +0000 | |
---|---|---|
committer | 2015-12-01 10:18:35 +0000 | |
commit | 64774a543c7a7397efe930da23941e9dd7400e0f (patch) | |
tree | 4ff79094d91025550ce269001c746b5e16cf7fc4 | |
parent | KNF (diff) | |
download | wireguard-openbsd-64774a543c7a7397efe930da23941e9dd7400e0f.tar.xz wireguard-openbsd-64774a543c7a7397efe930da23941e9dd7400e0f.zip |
Do not wait when allocating a page in vcpu_init().
Should help with the possible hang when trying to create a VM when
the host is out of memory. It also improves coherency as all the
allocations in vmm(4) are done without sleeping.
ok mlarkin@
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 1c9a60f79bc..64170292789 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.12 2015/12/01 10:14:05 mpi Exp $ */ +/* $OpenBSD: vmm.c,v 1.13 2015/12/01 10:18:35 mpi Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -1828,30 +1828,26 @@ vcpu_init_svm(struct vcpu *vcpu) int vcpu_init(struct vcpu *vcpu) { - int ret; + int ret = 0; - ret = 0; - vcpu->vc_hsa_stack_va = (vaddr_t)malloc(PAGE_SIZE, - M_DEVBUF, M_WAITOK | M_ZERO); + vcpu->vc_hsa_stack_va = (vaddr_t)malloc(PAGE_SIZE, M_DEVBUF, + M_NOWAIT|M_ZERO); if (!vcpu->vc_hsa_stack_va) return (ENOMEM); vcpu->vc_virt_mode = vmm_softc->mode; if (vmm_softc->mode == VMM_MODE_VMX || - vmm_softc->mode == VMM_MODE_EPT) { + vmm_softc->mode == VMM_MODE_EPT) ret = vcpu_init_vmx(vcpu); - if (ret) - free((void *)vcpu->vc_hsa_stack_va, M_DEVBUF, - PAGE_SIZE); - } else if (vmm_softc->mode == VMM_MODE_SVM || - vmm_softc->mode == VMM_MODE_RVI) { + else if (vmm_softc->mode == VMM_MODE_SVM || + vmm_softc->mode == VMM_MODE_RVI) ret = vcpu_init_svm(vcpu); - if (ret) - free((void *)vcpu->vc_hsa_stack_va, M_DEVBUF, - PAGE_SIZE); - } else + else panic("unknown vmm mode\n"); + if (ret) + free((void *)vcpu->vc_hsa_stack_va, M_DEVBUF, PAGE_SIZE); + return (ret); } |