public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Randolph Sapp <rs@ti.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>, <rs@ti.com>
Cc: <robertcnelson@gmail.com>, <ayush@beagleboard.org>,
	<Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,
	<trini@konsulko.com>, <afd@ti.com>, <xypron.glpk@gmx.de>,
	<u-boot@lists.denx.de>
Subject: Re: [PATCH 6/6] memory: reserve from start_addr_sp to relocaddr
Date: Thu, 2 Apr 2026 14:15:25 -0500	[thread overview]
Message-ID: <DHIWR5815YIB.2M5I1ZPQKVT8T@ti.com> (raw)
In-Reply-To: <CAC_iWj+VbbyyJS57DBMwbkCK2LoZi2WXu4pS11hRL+jzXXPpwA@mail.gmail.com>

On Thu Apr 2, 2026 at 4:21 AM CDT, Ilias Apalodimas wrote:
> On Thu, 2 Apr 2026 at 03:14, <rs@ti.com> wrote:
>>
>> From: Randolph Sapp <rs@ti.com>
>>
>> Reserve the memory from gd->start_addr_sp - CONFIG_STACK_SIZE to
>> gd->relocaddr instead of gd->ram_top. This allows platform specific
>> relocation addresses to work without unnecessarily painting over a large
>> range.
>
> This hangs when trying to boot with UEFI on QEMU aarch64.
> With the qemu_arm64_lwip_defconfig and this command line
>
> qemu-system-aarch64 -m 8192 -smp 2 -nographic -cpu cortex-a57 \
>     -machine virt,secure=off \
>     -bios u-boot.bin \
>     -device virtio-rng-pci \
>     -drive id=os,if=none,file=my.iso \
>     -device virtio-blk-device,drive=os \
>     -object memory-backend-ram,id=ram0,size=4G \
>     -object memory-backend-ram,id=ram1,size=4G \
>     -numa node,memdev=ram0 \
>     -numa node,memdev=ram1
>
> It also hangs when trying to initialize the EFI subsystem in general,
> e.g 'efidebug memmap', probably because some EFI code is relocated on
> the region you exlcuded.
>
> Thanks
> /Ilias

Thanks for the QEMU testcase. I see now there are a few cases where
gd->relocaddr can actually be decremented, meaning we won't actually cover the
entire u-boot memory region. I've added a new global data struct member
(end_addr_sp, but if anyone has any better name feel free to comment) to track
the original value of relocaddr set by setup_dest_addr and it works like a
charm.

I also realized that means I could cut out the PRAM and all of that bank
specific logic in lmb_reserve_uboot_region now, so that's cool.

>>
>> Signed-off-by: Randolph Sapp <rs@ti.com>
>> ---
>>  lib/efi_loader/efi_memory.c | 4 ++--
>>  lib/lmb.c                   | 2 +-
>>  2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
>> index f07cc39b157..57691d15758 100644
>> --- a/lib/efi_loader/efi_memory.c
>> +++ b/lib/efi_loader/efi_memory.c
>> @@ -915,8 +915,8 @@ static void add_u_boot_and_runtime(void)
>>         /* Add U-Boot */
>>         uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) -
>>                        uboot_stack_size) & ~EFI_PAGE_MASK;
>> -       uboot_pages = ((uintptr_t)map_sysmem(gd->ram_top - 1, 0) -
>> -                      uboot_start + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
>> +       uboot_pages = ((gd->relocaddr - uboot_start) + EFI_PAGE_MASK) >>
>> +                     EFI_PAGE_SHIFT;
>>         efi_update_memory_map(uboot_start, uboot_pages, EFI_BOOT_SERVICES_CODE,
>>                               false, false);
>>  #if defined(__aarch64__)
>> diff --git a/lib/lmb.c b/lib/lmb.c
>> index 542bb11dcf5..0df8157db7f 100644
>> --- a/lib/lmb.c
>> +++ b/lib/lmb.c
>> @@ -540,7 +540,7 @@ static void lmb_reserve_uboot_region(void)
>>         ulong pram = 0;
>>
>>         rsv_start = gd->start_addr_sp - CONFIG_STACK_SIZE;
>> -       end = gd->ram_top;
>> +       end = gd->relocaddr;
>>
>>         /*
>>          * Reserve memory from aligned address below the bottom of U-Boot stack
>> --
>> 2.53.0
>>


      reply	other threads:[~2026-04-02 19:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02  0:14 [PATCH 0/6] various memory related fixups rs
2026-04-02  0:14 ` [PATCH 1/6] lmb: add LMB_FDT for fdt reserved regions rs
2026-04-02  0:36   ` Randolph Sapp
2026-04-02  0:14 ` [PATCH 2/6] efi_dt_fixup: use fdtdec_get_bool rs
2026-04-02  8:38   ` Ilias Apalodimas
2026-04-02  0:14 ` [PATCH 3/6] efi_selftest_memory: check for duplicates first rs
2026-04-02  0:14 ` [PATCH 4/6] efi_memory: nitpick removal loop rs
2026-04-02  9:04   ` Ilias Apalodimas
2026-04-02 17:39     ` Randolph Sapp
2026-04-02 19:02       ` Ilias Apalodimas
2026-04-02 19:21         ` Randolph Sapp
2026-04-02  0:14 ` [PATCH 5/6] efi_memory: backfill EFI_CONVENTIONAL_MEMORY rs
2026-04-02  8:53   ` Ilias Apalodimas
2026-04-02 17:32     ` Randolph Sapp
2026-04-02 19:58       ` Randolph Sapp
2026-04-03  5:28         ` Ilias Apalodimas
2026-04-04  0:08           ` Randolph Sapp
2026-04-02  0:14 ` [PATCH 6/6] memory: reserve from start_addr_sp to relocaddr rs
2026-04-02  9:21   ` Ilias Apalodimas
2026-04-02 19:15     ` Randolph Sapp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DHIWR5815YIB.2M5I1ZPQKVT8T@ti.com \
    --to=rs@ti.com \
    --cc=Erik.Welsh@octavosystems.com \
    --cc=afd@ti.com \
    --cc=anshuld@ti.com \
    --cc=ayush@beagleboard.org \
    --cc=bb@ti.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=robertcnelson@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox