@samitouri / QOSamiQemu / commits / 66259fc5a2

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>

Richard Henderson committed May 29, 2026 at 15:36 UTC 66259fc5a2010704a3fa7a670519563dc98600b5
2 files changed +8 -21
linux-user/elfload.c
+7 -19
@@ -1092,20 +1092,11 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
1092 uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE);
1093
1094 /* Sanity check the guest binary. */
1095 - if (reserved_va) {
1096 - if (guest_hiaddr > reserved_va) {
1097 - error_report("%s: requires more than reserved virtual "
1098 - "address space (0x%" PRIx64 " > 0x%lx)",
1099 - image_name, (uint64_t)guest_hiaddr, reserved_va);
1100 - exit(EXIT_FAILURE);
1101 - }
1102 - } else {
1103 - if (guest_hiaddr != (uintptr_t)guest_hiaddr) {
1104 - error_report("%s: requires more virtual address space "
1105 - "than the host can provide (0x%" PRIx64 ")",
1106 - image_name, (uint64_t)guest_hiaddr + 1);
1107 - exit(EXIT_FAILURE);
1108 - }
1095 + if (reserved_va && guest_hiaddr > reserved_va) {
1096 + error_report("%s: requires more than reserved virtual "
1097 + "address space (0x%" PRIx64 " > 0x%lx)",
1098 + image_name, (uint64_t)guest_hiaddr, reserved_va);
1099 + exit(EXIT_FAILURE);
1100 }
1101
1102 if (have_guest_base) {
@@ -1373,11 +1364,8 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
1364 */
1365 probe_guest_base(image_name, range.lo, range.hi);
1366 } else {
1376 - /*
1377 - * The binary is dynamic, but we still need to
1378 - * select guest_base. In this case we pass a size.
1379 - */
1380 - probe_guest_base(image_name, 0, range.hi - range.lo);
1367 + /* The binary is dynamic; we still need to select guest_base. */
1368 + probe_guest_base(image_name, 0, 0);
1369
1370 /*
1371 * Avoid collision with the loader by providing a different
linux-user/flatload.c
+1 -2
@@ -261,8 +261,7 @@ static int load_flat_file(struct linux_binprm * bprm,
261 /*
262 * Allocate the address space.
263 */
264 - probe_guest_base(bprm->filename, 0,
265 - text_len + data_len + extra + indx_len - 1);
264 + probe_guest_base(bprm->filename, 0, 0);
265
266 /*
267 * there are a couple of cases here, the separate code/data