From 7eeadd7194ef45bfab4369ab223255ab997af60a Mon Sep 17 00:00:00 2001 From: mintsuki Date: Sun, 31 Oct 2021 05:17:37 +0100 Subject: [PATCH] elf: Fix bug related to overshoot check --- stage23/lib/elf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/stage23/lib/elf.c b/stage23/lib/elf.c index 76755969..6398c6ac 100644 --- a/stage23/lib/elf.c +++ b/stage23/lib/elf.c @@ -542,11 +542,6 @@ final: uint64_t this_top = load_addr + phdr.p_memsz; - // Make sure we don't overshoot - if (higher_half == true && this_top > 0x80000000) { - goto again; - } - if (top) { if (this_top > *top) { *top = this_top; @@ -564,7 +559,8 @@ final: } if (!fully_virtual && - !memmap_alloc_range((size_t)mem_base, (size_t)mem_size, alloc_type, true, false, simulation, false)) { + ((higher_half == true && this_top > 0x80000000) + || !memmap_alloc_range((size_t)mem_base, (size_t)mem_size, alloc_type, true, false, simulation, false))) { if (++try_count == max_simulated_tries || simulation == false) { panic("elf: Failed to allocate necessary memory ranges"); }