qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 13/14] linux-user: Adjust initial brk when interpreter is


From: Helge Deller
Subject: Re: [PATCH v7 13/14] linux-user: Adjust initial brk when interpreter is close to executable
Date: Thu, 3 Aug 2023 15:00:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

Hi Richard,

Thanks for putting this all together!
I'll test asap.

I haven't checked yet, but Akihiko did send a revised v2 patch
series, while my v6 series included his older v1 patches.
We should consider his latest series...

One other thing below....

On 8/3/23 03:53, Richard Henderson wrote:
From: Helge Deller <deller@gmx.de>

While we attempt to load a ET_DYN executable far away from
TASK_UNMAPPED_BASE, we are not completely in control of the
address space layout.  If the interpreter lands close to
the executable, leaving insufficient heap space, move brk.

Signed-off-by: Helge Deller <deller@gmx.de>
[rth: Re-order after ELF_ET_DYN_BASE patch so that we do not
  "temporarily break" tsan, and also to minimize the changes required.
  Remove image_info.reserve_brk as unused.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
  linux-user/qemu.h    |  1 -
  linux-user/elfload.c | 51 +++++++++++++-------------------------------
  2 files changed, 15 insertions(+), 37 deletions(-)
...
@@ -3229,7 +3208,8 @@ static void load_elf_image(const char *image_name, int 
image_fd,
      info->end_code = 0;
      info->start_data = -1;
      info->end_data = 0;
-    info->brk = 0;
+    /* Usual start for brk is after all sections of the main executable. */
+    info->brk = TARGET_PAGE_ALIGN(hiaddr);

This is from my original patch, and is probably wrong.
I think this needs to be:
    info->brk = HOST_PAGE_ALIGN(hiaddr);

The brk page needs to be aligned to the host page size variable (which
is always >= target page size).
The page will be mapped +rw (on host), so may need the distance to code/shared
libs below it, and for that distance target-alignment may not be sufficient.

I think this fixes the problem which joel faced with armel static binary
on ppc64le.

Helge



reply via email to

[Prev in Thread] Current Thread [Next in Thread]