Skip to content

Commit

Permalink
Use mmap rather than valloc in vmm_mem_alloc
Browse files Browse the repository at this point in the history
This will allow us to customise the flags in a later patch.

Signed-off-by: David Scott <[email protected]>
  • Loading branch information
djs55 committed Aug 20, 2019
1 parent c0dd463 commit 04f7bc8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib/vmm/vmm_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <Hypervisor/hv_vmx.h>
#include <xhyve/support/misc.h>
#include <xhyve/vmm/vmm_mem.h>

#include <sys/mman.h>
int
vmm_mem_init(void)
{
Expand All @@ -46,10 +46,9 @@ vmm_mem_alloc(uint64_t gpa, size_t size)
{
void *object;

object = valloc(size);

if (!object) {
xhyve_abort("vmm_mem_alloc failed\n");
object = mmap(0, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (object == MAP_FAILED) {
xhyve_abort("vmm_mem_alloc failed in mmap\n");
}

if (hv_vm_map(object, gpa, size,
Expand Down

0 comments on commit 04f7bc8

Please sign in to comment.