Attached is a patch to qemu which allows preallocation of huge pages at startup time. Also in cases where sufficient huge pages are not available, the user may request to selectively fall back to 4K pages for those portions of phys_mem which couldn't be backed by huge pages. This patch is relative to kvm-70. The motivation for this arose from odd behavior seen in qemu when access to huge page backed phys_mem failed during startup (eg: loading the bios), and during runtime where a guest will terminate via signal if a free hpage isn't available to satisfy a guest page fault. Two flags are introduced: -mem-prealloc [0|1] Attempt to fault-in all hpages and if all can be allocated proceed as normal. If all hpages can't be resolved and -mem-fallback behavior wasn't is requested, qemu will error exit. This behavior is enabled by default when -mem-path is specified. -mem-fallback [0|1] In the case some hpages can't be allocated, mapping a series of 4K pages will be attempted in place of them. In the case zero hpages were allocated a diagnostic to this effect will be printed (flagging scenarios such as /proc/sys/vm/nr_hugepages failing to be setup) and the normal non-hpage 4K allocation will be attempted. This behavior by default is disabled. Recognition of -mem-fallback will only occur when -mem-path is specified and -mem-prealloc behavior is enabled. This is believed to be an interim bandaid until such support is available from within the kernel+kvm, ideally allowing fallback to 4K pages on a dynamic basis and ultimately allowing huge pages faults to reclaim huge pages from other users in the system. -john Signed-off-by: john cooper redhat.com>