On Tue, 26 May 2026 at 00:03, Helge Deller <[email protected]> wrote:
>
> From: Helge Deller <[email protected]>
>
> Static built ARM binaries for Cortex-m55 may have been linked to have
> their load address at address 0. When qemu-user is running as non-root
> user and thus will try to mmap() a host address which is smaller than
> mmap_min_addr (/proc/sys/vm/mmap_min_addr), it will fail with EPERM and
> as such loading those guest programs will fail.
>
> Avoid this EPERM failure by automatically choosing a valid starting
> guest_base address which has to be higher than mmap_min_addr.
>
> Signed-off-by: Helge Deller <[email protected]>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1890
I just put a comment in this issue, but the reason we don't
load this binary is partly because it is not a Linux binary
at all, it is a bare-metal image. So the extent to which we
can run it at all is a mix of luck and "we like to let the GCC
developers be able to run their semihosting test binaries on
qemu-user".
> ---
> linux-user/elfload.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 0e757787d2..152c122a23 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -1033,8 +1033,9 @@ static void pgb_dynamic(const char *image_name,
> uintptr_t guest_loaddr,
> uintptr_t brk, ret;
> PGBAddrs ga;
>
> - /* Try the identity map first. */
> - if (pgb_addr_set(&ga, guest_loaddr, guest_hiaddr, true)) {
> + /* Try the identity map first if guest_loadaddr is above mmap_min_addr.
> */
> + if (guest_loaddr >= mmap_min_addr &&
> + pgb_addr_set(&ga, guest_loaddr, guest_hiaddr, true)) {
pgb_addr_set() is supposed to return false if the identity
map isn't suitable, so I feel like it would be better to
have it get the answer right rather than work around it
giving us the wrong answer in this particular case.
thanks
-- PMM