* [PATCH] bootm: Relocate RISC-V Linux Images before booting
@ 2026-10-19 16:13 Junhui Liu
2026-10-19 18:03 ` Tom Rini
2026-10-20 0:10 ` Yao Zi
0 siblings, 2 replies; 3+ messages in thread
From: Junhui Liu @ 2026-10-19 16:13 UTC (permalink / raw)
To: u-boot
Cc: Tom Rini, Aristo Chen, Simon Glass, Daniel Golle, Tim Ouyang,
Leo Liang, Yao Zi, Igor Opaniuk, Junhui Liu
RISC-V Linux requires the kernel Image to be loaded at a 2 MiB aligned
address for RV64, or a 4 MiB aligned address for RV32 [1]. When booting
a FIT image with a kernel_noload payload, or an Android boot image via
fastboot boot, the kernel may be placed at an address that does not
meet these alignment requirements and fail to boot.
As already done for ARM64, call booti_setup() for RISC-V Linux Images
to obtain a suitable load address and relocate the kernel before
booting. This reuses the existing RISC-V booti placement policy.
Link: https://docs.kernel.org/arch/riscv/boot.html#kernel-location [1]
Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
---
When testing Linux booting via fastboot on a RISC-V platform, I found
that the kernel failed to boot with the default Android boot image page
size:
=> fastboot udp
Using virtio-net#0 device
Listening for fastboot command on 10.0.2.15
Starting download of 27273216 bytes
..........................................................................
..........................................................................
............................................................
downloading of 27273216 bytes finished
Booting kernel at 0x0000000082000000...
## Booting Android Image at 0x82000000 ...
Kernel load addr 0x82000800 size 24849 KiB
RAM disk load addr 0x83845000 size 1776 KiB
Working FDT set to 83a01000
XIP Kernel Image to 82000800
Loading Device Tree to 000000009de87000, end 000000009de8b3b3 ... OK
Working FDT set to 9de87000
No RNG device
Starting kernel ...
No kernel output followed. The kernel Image was placed at 0x82000800,
which does not meet the 2 MiB alignment requirement for RV64 Linux.
The 0x800 offset comes from the default Android boot image page size
used by fastboot. Passing --page-size 0x200000 works around the issue
in this setup by placing the kernel at 0x82200000.
ARM64 already handles kernel relocation in bootm by calling
booti_setup(). This patch extends that handling to RISC-V, reusing
the existing RISC-V booti placement policy without changing the
booti path.
The existing RISC-V booti_setup() relocates Images loaded in RAM to
ram_base + text_offset without explicitly aligning the address.
The RAM bases defined by the current RISC-V platforms are 4 MiB
aligned, while the standard Linux Image text_offset is 2 MiB for
RV64 and 4 MiB for RV32, so this placement satisfies the alignment
requirements.
If a future platform has an unaligned RAM base, a separate patch
will be needed to handle alignment in the RISC-V booti_setup(),
also benefiting the regular booti path.
For the Android boot image case, this depends on Igor's "bootm: set
os.arch for Android boot images" patch:
https://patch.msgid.link/20261012-upstream-bootm_android_b4-v2-1-4c18a34550a1@oss.qualcomm.com
---
boot/bootm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/boot/bootm.c b/boot/bootm.c
index 92c8452a5d35..ade241f3a337 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -883,15 +883,15 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
}
}
- if (IS_ENABLED(CONFIG_CMD_BOOTI) && images->os.arch == IH_ARCH_ARM64 &&
- images->os.os == IH_OS_LINUX) {
+ if (IS_ENABLED(CONFIG_CMD_BOOTI) && images->os.os == IH_OS_LINUX &&
+ (images->os.arch == IH_ARCH_ARM64 || images->os.arch == IH_ARCH_RISCV)) {
ulong relocated_addr;
ulong image_size;
int ret;
ret = booti_setup(load, &relocated_addr, &image_size, false);
if (ret) {
- printf("Failed to prep arm64 kernel (err=%d)\n", ret);
+ printf("Failed to prep kernel image (err=%d)\n", ret);
return BOOTM_ERR_RESET;
}
---
base-commit: 8d534cec0cc0109a37c0ded8854da03f1526dc0e
change-id: 20261019-bootm-riscv-image-relocation-b34c6a5d9496
Best regards,
--
Junhui Liu <junhui.liu@pigmoral.tech>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] bootm: Relocate RISC-V Linux Images before booting
2026-10-19 16:13 [PATCH] bootm: Relocate RISC-V Linux Images before booting Junhui Liu
@ 2026-10-19 18:03 ` Tom Rini
2026-10-20 0:10 ` Yao Zi
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2026-10-19 18:03 UTC (permalink / raw)
To: Junhui Liu
Cc: u-boot, Aristo Chen, Simon Glass, Daniel Golle, Tim Ouyang,
Leo Liang, Yao Zi, Igor Opaniuk
[-- Attachment #1: Type: text/plain, Size: 817 bytes --]
On Tue, Oct 20, 2026 at 12:13:03AM +0800, Junhui Liu wrote:
> RISC-V Linux requires the kernel Image to be loaded at a 2 MiB aligned
> address for RV64, or a 4 MiB aligned address for RV32 [1]. When booting
> a FIT image with a kernel_noload payload, or an Android boot image via
> fastboot boot, the kernel may be placed at an address that does not
> meet these alignment requirements and fail to boot.
>
> As already done for ARM64, call booti_setup() for RISC-V Linux Images
> to obtain a suitable load address and relocate the kernel before
> booting. This reuses the existing RISC-V booti placement policy.
>
> Link: https://docs.kernel.org/arch/riscv/boot.html#kernel-location [1]
> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bootm: Relocate RISC-V Linux Images before booting
2026-10-19 16:13 [PATCH] bootm: Relocate RISC-V Linux Images before booting Junhui Liu
2026-10-19 18:03 ` Tom Rini
@ 2026-10-20 0:10 ` Yao Zi
1 sibling, 0 replies; 3+ messages in thread
From: Yao Zi @ 2026-10-20 0:10 UTC (permalink / raw)
To: Junhui Liu, u-boot
Cc: Tom Rini, Aristo Chen, Simon Glass, Daniel Golle, Tim Ouyang,
Leo Liang, Yao Zi, Igor Opaniuk
On Tue, Oct 20, 2026 at 12:13:03AM +0800, Junhui Liu wrote:
> RISC-V Linux requires the kernel Image to be loaded at a 2 MiB aligned
> address for RV64, or a 4 MiB aligned address for RV32 [1]. When booting
> a FIT image with a kernel_noload payload, or an Android boot image via
> fastboot boot, the kernel may be placed at an address that does not
> meet these alignment requirements and fail to boot.
>
> As already done for ARM64, call booti_setup() for RISC-V Linux Images
> to obtain a suitable load address and relocate the kernel before
> booting. This reuses the existing RISC-V booti placement policy.
>
> Link: https://docs.kernel.org/arch/riscv/boot.html#kernel-location [1]
> Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
Reviewed-by: Yao Zi <me@ziyao.cc>
Thanks,
Yao Zi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-20 0:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 16:13 [PATCH] bootm: Relocate RISC-V Linux Images before booting Junhui Liu
2026-10-19 18:03 ` Tom Rini
2026-10-20 0:10 ` Yao Zi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.