* [Qemu-devel] [PATCH v3] linux-user: fix mmap_find_vma_reserved()
@ 2018-07-14 19:35 Laurent Vivier
2018-07-15 0:45 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2018-07-14 19:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Riku Voipio, Richard Henderson
The value given by mmap_find_vma_reserved() is used with mmap(),
so it is needed to be aligned with the host page size.
Since commit 18e80c55bb, reserved_va is only aligned to TARGET_PAGE_SIZE,
and it works well if this size is greater or equal to the host page size.
But ppc64 hosts have 64kB page size and when we start a 4kiB page size
guest (like i386), it fails when it tries to mmap the stack:
mmap stack: Invalid argument
Fixes: 18e80c55bb (linux-user: Tidy and enforce reserved_va initialization)
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
Notes:
v3:
move initialization of reserved_va to main()
v2:
fix typo s/has/as/
linux-user/main.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 52b5a618fe..ea00dd9057 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -78,14 +78,7 @@ int have_guest_base;
# endif
#endif
-/* That said, reserving *too* much vm space via mmap can run into problems
- with rlimits, oom due to page table creation, etc. We will still try it,
- if directed by the command-line option, but not by default. */
-#if HOST_LONG_BITS == 64 && TARGET_VIRT_ADDR_SPACE_BITS <= 32
-unsigned long reserved_va = MAX_RESERVED_VA;
-#else
unsigned long reserved_va;
-#endif
static void usage(int exitcode);
@@ -672,6 +665,18 @@ int main(int argc, char **argv, char **envp)
/* init tcg before creating CPUs and to get qemu_host_page_size */
tcg_exec_init(0);
+ /* Reserving *too* much vm space via mmap can run into problems
+ with rlimits, oom due to page table creation, etc. We will still try it,
+ if directed by the command-line option, but not by default. */
+ if (HOST_LONG_BITS == 64 &&
+ TARGET_VIRT_ADDR_SPACE_BITS <= 32 &&
+ reserved_va == 0) {
+ /* reserved_va must be aligned with the host page size
+ * as it is used with mmap()
+ */
+ reserved_va = MAX_RESERVED_VA & qemu_host_page_mask;
+ }
+
cpu = cpu_create(cpu_type);
env = cpu->env_ptr;
cpu_reset(cpu);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v3] linux-user: fix mmap_find_vma_reserved()
2018-07-14 19:35 [Qemu-devel] [PATCH v3] linux-user: fix mmap_find_vma_reserved() Laurent Vivier
@ 2018-07-15 0:45 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2018-07-15 0:45 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Riku Voipio
On 07/14/2018 02:35 PM, Laurent Vivier wrote:
> The value given by mmap_find_vma_reserved() is used with mmap(),
> so it is needed to be aligned with the host page size.
>
> Since commit 18e80c55bb, reserved_va is only aligned to TARGET_PAGE_SIZE,
> and it works well if this size is greater or equal to the host page size.
>
> But ppc64 hosts have 64kB page size and when we start a 4kiB page size
> guest (like i386), it fails when it tries to mmap the stack:
>
> mmap stack: Invalid argument
>
> Fixes: 18e80c55bb (linux-user: Tidy and enforce reserved_va initialization)
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>
> Notes:
> v3:
> move initialization of reserved_va to main()
>
> v2:
> fix typo s/has/as/
>
> linux-user/main.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-15 0:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-14 19:35 [Qemu-devel] [PATCH v3] linux-user: fix mmap_find_vma_reserved() Laurent Vivier
2018-07-15 0:45 ` Richard Henderson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.