summary refs log tree commit diff stats
path: root/linux-user/elfload.c
diff options
context:
space:
mode:
authorXinyu Li <precinct@mail.ustc.edu.cn>2019-12-13 10:29:19 +0800
committerLaurent Vivier <laurent@vivier.eu>2020-01-22 14:59:22 +0100
commit91c8bdb1e6690fa2b6f107613271ae923126f098 (patch)
tree6ba19ba02f9e5cd9d66e8ef57f8834daa477adf0 /linux-user/elfload.c
parent3e08b2b9cb64bff2b73fa9128c0e49bfcde0dd40 (diff)
downloadfocaccia-qemu-91c8bdb1e6690fa2b6f107613271ae923126f098.tar.gz
focaccia-qemu-91c8bdb1e6690fa2b6f107613271ae923126f098.zip
linux-user:Fix align mistake when mmap guest space
In init_guest_space, we need to mmap guest space. If the return address
of first mmap is not aligned with align, which was set to MAX(SHMLBA,
qemu_host_page_size), we need unmap and a new mmap(space is larger than
first size). The new size is named real_size, which is aligned_size +
qemu_host_page_size. alugned_size is the guest space size. And add a
qemu_host_page_size to avoid memory error when we align real_start
manually (ROUND_UP(real_start, align)). But when SHMLBA >
qemu_host_page_size, the added size will smaller than the size to align,
which can make a mistake(in a mips machine, it appears). So change
real_size from aligned_size +qemu_host_page_size
to aligned_size + align will solve it.

Signed-off-by: Xinyu Li <precinct@mail.ustc.edu.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20191213022919.5934-1-precinct@mail.ustc.edu.cn>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r--linux-user/elfload.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 07b16cc0f4..511e450078 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2191,7 +2191,7 @@ unsigned long init_guest_space(unsigned long host_start,
              * to where we need to put the commpage.
              */
             munmap((void *)real_start, host_size);
-            real_size = aligned_size + qemu_host_page_size;
+            real_size = aligned_size + align;
             real_start = (unsigned long)
                 mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0);
             if (real_start == (unsigned long)-1) {