unicorn/qemu/util
Murilo Opsfelder Araujo 0010078e4b
mmap-alloc: fix hugetlbfs misaligned length in ppc64
The commit 7197fb4058bcb68986bae2bb2c04d6370f3e7218 ("util/mmap-alloc:
fix hugetlb support on ppc64") fixed Huge TLB mappings on ppc64.

However, we still need to consider the underlying huge page size
during munmap() because it requires that both address and length be a
multiple of the underlying huge page size for Huge TLB mappings.
Quote from "Huge page (Huge TLB) mappings" paragraph under NOTES
section of the munmap(2) manual:

"For munmap(), addr and length must both be a multiple of the
underlying huge page size."

On ppc64, the munmap() in qemu_ram_munmap() does not work for Huge TLB
mappings because the mapped segment can be aligned with the underlying
huge page size, not aligned with the native system page size, as
returned by getpagesize().

This has the side effect of not releasing huge pages back to the pool
after a hugetlbfs file-backed memory device is hot-unplugged.

This patch fixes the situation in qemu_ram_mmap() and
qemu_ram_munmap() by considering the underlying page size on ppc64.

After this patch, memory hot-unplug releases huge pages back to the
pool.

Fixes: 7197fb4058bcb68986bae2bb2c04d6370f3e7218

Backports commit 53adb9d43e1abba187387a51f238e878e934c647 from qemu
2019-02-05 16:52:39 -05:00
..
bitmap.c
bitops.c
cacheinfo.c
crc32c.c
cutils.c
error.c
getauxval.c
host-utils.c
log.c
Makefile.objs
mmap-alloc.c mmap-alloc: fix hugetlbfs misaligned length in ppc64 2019-02-05 16:52:39 -05:00
module.c
oslib-posix.c mmap-alloc: fix hugetlbfs misaligned length in ppc64 2019-02-05 16:52:39 -05:00
oslib-win32.c
qemu-error.c
qemu-thread-posix.c qemu-thread: Don't block SEGV, ILL and FPE 2019-01-13 19:50:32 -05:00
qemu-thread-win32.c
qemu-timer-common.c
range.c Don't talk about the LGPL if the file is licensed under the GPL 2019-02-03 17:55:28 -05:00
sys_membarrier.c