From: Richard Henderson <richard.henderson@linaro.org>
To: Helge Deller <deller@gmx.de>, qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
Paolo Bonzini <pbonzini@redhat.com>,
Joel Stanley <joel@jms.id.au>,
Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory
Date: Wed, 2 Aug 2023 11:36:24 -0700 [thread overview]
Message-ID: <5b57cd92-149e-5f72-d946-082ebf0bfc9c@linaro.org> (raw)
In-Reply-To: <20230801232745.4125-9-deller@gmx.de>
On 8/1/23 16:27, Helge Deller wrote:
> +/* where to map binaries? */
> +#if HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
> +# define TASK_UNMAPPED_BASE_PIE 0x5500000000
> +# define TASK_UNMAPPED_BASE 0x7000000000
> +#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
> +# define TASK_UNMAPPED_BASE_PIE 0x00300000
> +# define TASK_UNMAPPED_BASE (GUEST_ADDR_MAX - 0x20000000 + 1)
> +#else /* HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32 */
> +# define TASK_UNMAPPED_BASE_PIE 0x00000000
> +# define TASK_UNMAPPED_BASE 0x40000000
> +#endif
It would probably be easier to follow if you use the kernel's name: ELF_ET_DYN_BASE.
Should be in linux-user/$GUEST/target_mmap.h with TASK_UNMAPPED_BASE, per my comment vs
patch 7.
> + /* do sanity checks on guest memory layout */
> + if (mmap_next_start >= GUEST_ADDR_MAX) {
> + mmap_next_start = GUEST_ADDR_MAX - 0x1000000000 + 1;
> + }
What in the world is that random number? It certainly won't compile on 32-bit host, and
certainly isn't relevant to a 32-bit guest.
> + if (TASK_UNMAPPED_BASE_PIE >= mmap_next_start) {
> + fprintf(stderr, "Memory too small for PIE executables.\n");
> + exit(EXIT_FAILURE);
> + }
Really bad timing for this diagnostic. What if a PIE executable isn't even being used?
Both TASK_UNMAPPED_BASE and ELF_ET_DYN_BASE could be computed in main (or a subroutine),
when reserved_va is assigned.
r~
next prev parent reply other threads:[~2023-08-02 18:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 23:27 [PATCH v6 0/8] linux-user: brk fixes Helge Deller
2023-08-01 23:27 ` [PATCH v6 1/8] linux-user: Unset MAP_FIXED_NOREPLACE for host Helge Deller
2023-08-01 23:40 ` Richard Henderson
2023-08-01 23:27 ` [PATCH v6 2/8] linux-user: Do not call get_errno() in do_brk() Helge Deller
2023-08-01 23:27 ` [PATCH v6 3/8] linux-user: Use MAP_FIXED_NOREPLACE for do_brk() Helge Deller
2023-08-01 23:27 ` [PATCH v6 4/8] linux-user: Do nothing if too small brk is specified Helge Deller
2023-08-01 23:27 ` [PATCH v6 5/8] linux-user: Do not align brk with host page size Helge Deller
2023-08-01 23:27 ` [PATCH v6 6/8] linux-user: Show heap address in /proc/pid/maps Helge Deller
2023-08-02 5:41 ` Philippe Mathieu-Daudé
2023-08-02 6:07 ` Helge Deller
2023-08-01 23:27 ` [PATCH v6 7/8] linux-user: Optimize memory layout for static and dynamic executables Helge Deller
2023-08-02 18:25 ` Richard Henderson
2023-08-02 19:51 ` Helge Deller
2023-08-02 19:57 ` Richard Henderson
2023-08-02 20:06 ` Helge Deller
2023-08-01 23:27 ` [PATCH v6 8/8] linux-user: Load pie executables at upper memory Helge Deller
2023-08-02 7:49 ` Akihiko Odaki
2023-08-02 8:42 ` Helge Deller
2023-08-02 8:44 ` Akihiko Odaki
2023-08-02 9:34 ` Helge Deller
2023-08-02 9:58 ` Akihiko Odaki
2023-08-02 10:35 ` Helge Deller
2023-08-02 18:36 ` Richard Henderson [this message]
2023-08-02 19:57 ` Helge Deller
2023-08-02 2:21 ` [PATCH v6 0/8] linux-user: brk fixes Joel Stanley
2023-08-02 6:10 ` Helge Deller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5b57cd92-149e-5f72-d946-082ebf0bfc9c@linaro.org \
--to=richard.henderson@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=deller@gmx.de \
--cc=joel@jms.id.au \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).