From: Helge Deller <[email protected]> Static built ARM binaries for Cortex-m55 may have been linked to have their load address at address 0 (because they are effectively a bare-metal image). When qemu-user is running as non-root user and will try to mmap() a host address at 0 (which is smaller than mmap_min_addr according to /proc/sys/vm/mmap_min_addr), it will fail with EPERM and as such loading those guest program will fail.
Fix pgb_addr_set() to always return false if the guest_loaddr < mmap_min_addr, that way a valdid guest_base address will be calculated and the EPERM can be avoided. Signed-off-by: Helge Deller <[email protected]> Suggested-by: Peter Maydell <[email protected]> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1890 --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f7625c0952..62f12e4149 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -866,7 +866,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr, if (LO_COMMPAGE != -1 && LO_COMMPAGE < mmap_min_addr) { return false; } - if (guest_loaddr != 0 && guest_loaddr < mmap_min_addr) { + if (guest_loaddr < mmap_min_addr) { return false; } } -- 2.54.0
