From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCkQr-0005w8-9i for qemu-devel@nongnu.org; Mon, 10 Feb 2014 01:33:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCkQj-00021W-1z for qemu-devel@nongnu.org; Mon, 10 Feb 2014 01:33:29 -0500 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:56315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCkQi-00021F-2i for qemu-devel@nongnu.org; Mon, 10 Feb 2014 01:33:21 -0500 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Feb 2014 16:33:15 +1000 From: Alexey Kardashevskiy Date: Mon, 10 Feb 2014 17:32:55 +1100 Message-Id: <1392013975-1656-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [RFC PATCH] file ram alloc: fail if cannot preallocate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf At the moment if the user asked for huge pages and there is no more huge pages, QEMU prints warning and falls back to the anonymous memory allocator which is quite easy not to notice. QEMU also does so even if the user specified -mem-prealloc and it seems wrong as the user specifically requested huge pages for the entire RAM but QEMU failed to do so and continued. On PPC64 this will produce a fragile guest as QEMU tells the guest via device-tree that it can use huge pages when it actually cannot. This adds message+exit if RAM cannot be preallocated from huge pages. Signed-off-by: Alexey Kardashevskiy --- exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exec.c b/exec.c index 9ad0a4b..deb8279 100644 --- a/exec.c +++ b/exec.c @@ -1041,6 +1041,10 @@ static void *file_ram_alloc(RAMBlock *block, area = mmap(0, memory, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (area == MAP_FAILED) { + if (mem_prealloc) { + perror("file_ram_alloc: failed to preallocate RAM"); + exit(1); + } perror("file_ram_alloc: can't mmap RAM pages"); close(fd); return (NULL); -- 1.8.4.rc4