Index: kvm-userspace/qemu/vl.c =================================================================== --- kvm-userspace.orig/qemu/vl.c +++ kvm-userspace/qemu/vl.c @@ -8501,6 +8501,31 @@ void qemu_get_launch_info(int *argc, cha *opt_incoming = incoming; } +#define HPAGE_SIZE 2*1024*1024 + +void *alloc_huge_area(unsigned long memory) +{ + void *area; + int fd; + char path[] = "/mnt/kvm.XXXXXX"; + + mkstemp(path); + fd = open(path, O_RDWR); + if (fd < 0) { + perror("open"); + exit(0); + } + memory = (memory+HPAGE_SIZE-1) & ~(HPAGE_SIZE-1); + + area = mmap(0, memory, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + if (area == MAP_FAILED) { + perror("mmap"); + exit(0); + } + + return area; +} + int main(int argc, char **argv) { #ifdef CONFIG_GDBSTUB @@ -9330,9 +9355,9 @@ int main(int argc, char **argv) ret = kvm_qemu_check_extension(KVM_CAP_USER_MEMORY); if (ret) { - printf("allocating %d MB\n", phys_ram_size/1024/1024); - phys_ram_base = qemu_vmalloc(phys_ram_size); - if (!phys_ram_base) { + //phys_ram_base = qemu_vmalloc(phys_ram_size); + phys_ram_base = alloc_huge_area(phys_ram_size); + if (!phys_ram_base) { fprintf(stderr, "Could not allocate physical memory\n"); exit(1); }