qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Andreas Schwab <schwab@suse.de>, qemu-devel@nongnu.org
Subject: Re: linux-user cannot allocate stack memory on riscv64 host due to non-zero guest_base
Date: Tue, 25 Jun 2024 08:47:32 -0700	[thread overview]
Message-ID: <9f3cb0e3-c069-497d-81de-234db7bd4d33@linaro.org> (raw)
In-Reply-To: <mvm8qytp828.fsf@suse.de>

On 6/25/24 04:37, Andreas Schwab wrote:
> When running qemu-riscv64 on a riscv64 host executing a ET_EXEC riscv64
> binary it cannot allocate memory for the stack:
> 
> $ qemu-riscv64 -d page ./hello.riscv64
> host mmap_min_addr=0x10000
> Locating guest address space @ 0x3ee000
> page layout changed following mmap
> start            end              size             prot
> 0000000000010000-0000000000013000 0000000000003000 ---
> page layout changed following mmap
> start            end              size             prot
> 0000000000010000-0000000000011000 0000000000001000 r-x
> 0000000000011000-0000000000013000 0000000000002000 ---
> page layout changed following mmap
> start            end              size             prot
> 0000000000010000-0000000000011000 0000000000001000 r-x
> 0000000000011000-0000000000013000 0000000000002000 rw-
> mmap stack: Cannot allocate memory
> 
> The issue is that guest_base is non-zero, which turns the target_mmap
> call with zero base in setup_arg_pages into a host mmap call with
> non-zero base.  On other hosts like x86_64 or aarch64, guest_base
> remains zero and the issue does not occur.

You need to be more precise in your bug reports, because it works for me.
Everything non-PIE, statically linked:

./qemu-riscv64: ELF 64-bit LSB executable, UCB RISC-V, RVC, double-float ABI, version 1 
(SYSV), statically linked, BuildID[sha1]=92e2b4b9a2cbcc91ac029a49ec72eaefe5111f38, for 
GNU/Linux 4.15.0, with debug_info, not stripped

/home/rth/a.out: ELF 64-bit LSB executable, UCB RISC-V, RVC, double-float ABI, version 1 
(SYSV), statically linked, BuildID[sha1]=4c52c576a0452e97d9117b89dd317c88460b0768, for 
GNU/Linux 4.15.0, not stripped

$ ./qemu-riscv64 -d page ~/a.out
host mmap_min_addr=0x1000
Locating guest address space @ 0x3ff000
page layout changed following mmap
start            end              size             prot
0000000000010000-0000000000084000 0000000000074000 ---
...
end_code    0x0000000000078388
start_code  0x0000000000010000
start_data  0x00000000000795b0
end_data    0x000000000007e8a8
start_stack 0x0000003f812224a0
brk         0x0000000000084000
entry       0x000000000001041c
argv_start  0x0000003f812224a8
env_start   0x0000003f812224b8
auxv_start  0x0000003f81222570
...
Hello, World!


I don't doubt that you see a problem, but I need a reproducer, not a guess as to what the 
problem might be.  Certainly guest_base is *not* it.  One can always force the use of a 
non-zero base with -B or -R.


r~


  reply	other threads:[~2024-06-25 15:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 11:37 linux-user cannot allocate stack memory on riscv64 host due to non-zero guest_base Andreas Schwab
2024-06-25 15:47 ` Richard Henderson [this message]
2024-06-26  8:23   ` Andreas Schwab
2024-06-26 15:48     ` Richard Henderson
2024-06-26 15:54       ` Warner Losh
2024-06-27  7:54         ` Andreas Schwab
2024-06-27 14:14           ` Warner Losh
2024-06-27 14:26             ` Andreas Schwab
2024-06-27 14:55               ` Peter Maydell
2024-07-01 14:02                 ` Andreas Schwab
2024-07-01 16:05                   ` Richard Henderson
2024-07-02  8:09                     ` Andreas Schwab
2024-07-02 14:13                       ` Richard Henderson
2024-07-02 14:18                         ` Andreas Schwab
2024-07-02 14:18                       ` Richard Henderson
2024-07-02 14:39                         ` Andreas Schwab
2024-07-02 14:45                           ` Richard Henderson
2024-07-02 13:37                     ` Andreas Schwab

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=9f3cb0e3-c069-497d-81de-234db7bd4d33@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=schwab@suse.de \
    /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).