]> git.proxmox.com Git - mirror_qemu.git/commit - exec.c
exec: Fix memory allocation when memory path isn't on hugetlbfs
authorMarkus Armbruster <armbru@redhat.com>
Mon, 7 Mar 2016 19:25:14 +0000 (20:25 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 15 Mar 2016 17:23:33 +0000 (18:23 +0100)
commite1fb6471999939539ecfb21b41cbbb24047fa4dc
tree134b243bb9217b2547700d5b105c6ad99d8ee633
parentfd97fd4408040a9a6dfaf2fdaeca1c566db6d0aa
exec: Fix memory allocation when memory path isn't on hugetlbfs

gethugepagesize() works reliably only when its argument is on
hugetlbfs.  When it's not, it returns the filesystem's "optimal
transfer block size", which may or may not be the actual page size
you'll get when you mmap().

If the value is too small or not a power of two, we fail
qemu_ram_mmap()'s assertions.  These were added in commit 794e8f3
(v2.5.0).  The bug's impact before that is currently unknown.  Seems
fairly unlikely at least when the normal page size is 4KiB.

Else, if the value is too large, we align more strictly than
necessary.

gethugepagesize() goes back to commit c902760 (v0.13).  That commit
clearly intended gethugepagesize() to be used on hugetlbfs only.  Not
only was it named accordingly, it also printed a warning when used on
anything else.  However, the commit neglected to spell out the
restriction in user documentation of -mem-path.

Commit bfc2a1a (v2.5.0) dropped the warning as bogus "because QEMU
functions perfectly well with the path on a regular tmpfs filesystem".
It sure does when you're sufficiently lucky.  In my testing, I was
lucky, too.

Fix by switching to qemu_fd_getpagesize().  Rename the variable
holding its result from hpagesize to page_size.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1457378754-21649-3-git-send-email-armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c