Commit 66259fc5a2 for qemu.org
commit 66259fc5a2010704a3fa7a670519563dc98600b5
Author: Richard Henderson <richard.henderson@linaro.org>
Date: Fri May 29 15:36:31 2026 -0700
linux-user: Drop hiaddr out-of-range check in probe_guest_base
Since dropping 32-bit host support, a guest address cannot
overflow a host pointer. This means guest_hiaddr is unused
for relocatable images, so don't pass guest_hiaddr as size.
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 30d7beb562..1367657d58 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1092,20 +1092,11 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE);
/* Sanity check the guest binary. */
- if (reserved_va) {
- if (guest_hiaddr > reserved_va) {
- error_report("%s: requires more than reserved virtual "
- "address space (0x%" PRIx64 " > 0x%lx)",
- image_name, (uint64_t)guest_hiaddr, reserved_va);
- exit(EXIT_FAILURE);
- }
- } else {
- if (guest_hiaddr != (uintptr_t)guest_hiaddr) {
- error_report("%s: requires more virtual address space "
- "than the host can provide (0x%" PRIx64 ")",
- image_name, (uint64_t)guest_hiaddr + 1);
- exit(EXIT_FAILURE);
- }
+ if (reserved_va && guest_hiaddr > reserved_va) {
+ error_report("%s: requires more than reserved virtual "
+ "address space (0x%" PRIx64 " > 0x%lx)",
+ image_name, (uint64_t)guest_hiaddr, reserved_va);
+ exit(EXIT_FAILURE);
}
if (have_guest_base) {
@@ -1373,11 +1364,8 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
*/
probe_guest_base(image_name, range.lo, range.hi);
} else {
- /*
- * The binary is dynamic, but we still need to
- * select guest_base. In this case we pass a size.
- */
- probe_guest_base(image_name, 0, range.hi - range.lo);
+ /* The binary is dynamic; we still need to select guest_base. */
+ probe_guest_base(image_name, 0, 0);
/*
* Avoid collision with the loader by providing a different
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 4beb3ed1b9..8abdd2aef2 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -261,8 +261,7 @@ static int load_flat_file(struct linux_binprm * bprm,
/*
* Allocate the address space.
*/
- probe_guest_base(bprm->filename, 0,
- text_len + data_len + extra + indx_len - 1);
+ probe_guest_base(bprm->filename, 0, 0);
/*
* there are a couple of cases here, the separate code/data