Re: [PATCH] platform: Fix payload alignment when FW_TEXT_START isn't 2M/4M aligned

Anup Patel <[email protected]> Fri, 12 Jun 2026 08:58:39 +0530
Newsgroups org.infradead.lists.opensbi
Message-ID <CAAhSdy2Szq+ER882cdOR3VYgxLioXMh_f2LND=7X3GmzhoOtag@mail.gmail.com>
On Fri, May 8, 2026 at 10:02 PM Anirudh Srinivasan
<[email protected]> wrote:
>
> The payload for FW_PAYLOAD needs to be placed at a 2M/4M aligned address
> (for 64/32 bit systems) and the current makefile uses FW_PAYLOAD_OFFSET
> to achieve this. This only works if FW_TEXT_START is already 2M/4M
> aligned. Most existing physical/virtual platforms have used a
> FW_TEXT_START of 0x0 or 0x80000000, so this hasn't been an issue so far.
> If, for example, FW_TEXT_START is 0x80000, the payload would end up
> placed at 0x280000 on a 64 bit system, which isn't a 2M aligned
> address.
>
> Update the makefile to use FW_PAYLOAD_ALIGN instead. This will ensure
> that the address picked for the payload is 2M/4M aligned irrespective of
> where FW_TEXT_START is.
>
> Signed-off-by: Anirudh Srinivasan <[email protected]>

LGTM.

Reviewed-by: Anup Patel <[email protected]>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
> To: [email protected]
> ---
>  platform/generic/objects.mk  | 4 ++--
>  platform/template/objects.mk | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/platform/generic/objects.mk b/platform/generic/objects.mk
> index c4a8fee2..ca7fb8b7 100644
> --- a/platform/generic/objects.mk
> +++ b/platform/generic/objects.mk
> @@ -35,9 +35,9 @@ FW_JUMP_FDT_OFFSET=0x2200000
>  FW_PAYLOAD=y
>  ifeq ($(PLATFORM_RISCV_XLEN), 32)
>    # This needs to be 4MB aligned for 32-bit system
> -  FW_PAYLOAD_OFFSET=0x400000
> +  FW_PAYLOAD_ALIGN=0x400000
>  else
>    # This needs to be 2MB aligned for 64-bit system
> -  FW_PAYLOAD_OFFSET=0x200000
> +  FW_PAYLOAD_ALIGN=0x200000
>  endif
>  FW_PAYLOAD_FDT_OFFSET=$(FW_JUMP_FDT_OFFSET)
> diff --git a/platform/template/objects.mk b/platform/template/objects.mk
> index f240a557..9b4bc928 100644
> --- a/platform/template/objects.mk
> +++ b/platform/template/objects.mk
> @@ -85,11 +85,11 @@ FW_PAYLOAD=<y|n>
>  # This needs to be 4MB aligned for 32-bit support
>  # This needs to be 2MB aligned for 64-bit support
>  ifeq ($(PLATFORM_RISCV_XLEN), 32)
> -FW_PAYLOAD_OFFSET=0x400000
> +FW_PAYLOAD_ALIGN=0x400000
>  else
> -FW_PAYLOAD_OFFSET=0x200000
> +FW_PAYLOAD_ALIGN=0x200000
>  endif
> -# FW_PAYLOAD_ALIGN=0x1000
> +# FW_PAYLOAD_OFFSET=0x400000
>  # FW_PAYLOAD_PATH="path to next boot stage binary image file"
>  # FW_PAYLOAD_FDT_OFFSET=0x2200000
>  #
>
> ---
> base-commit: 2257e9957103aac7df8089a59b9d4bdda7c592ce
> change-id: 20260508-payload_alignment-5585a86ec7e4
>
> Best regards,
> --
> Anirudh Srinivasan <[email protected]>
>
>
> --
> opensbi mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/opensbi

-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi