From b9191c9498521b94cf6a4695ca1d3dc08e6284f0 Mon Sep 17 00:00:00 2001 From: George Poulios Date: Mon, 24 Feb 2025 17:28:48 +0200 Subject: [PATCH] arch/arm64: fix boot stage prints with CONFIG_ARCH_EARLY_PRINT=y `boot_stage_puts` used by early asm calls arm64_lowputc() for each character in a loop. During that loop it uses x1 as the pointer to the next character to be printed. However, x1 is clobbered by arm64_lowputc(), resulting in undefined behaviour (only the first character of the string is guaranteed to be printed). Fix this by using x19 instead. Signed-off-by: George Poulios --- arch/arm64/src/common/arm64_head.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/src/common/arm64_head.S b/arch/arm64/src/common/arm64_head.S index 6ddfc556448aa..7d210d1233ffa 100644 --- a/arch/arm64/src/common/arm64_head.S +++ b/arch/arm64/src/common/arm64_head.S @@ -365,15 +365,16 @@ out: */ boot_stage_puts: - stp xzr, x30, [sp, #-16]! + stp x19, x30, [sp, #-16]! + mov x19, x1 1: - ldrb w0, [x1], #1 /* Load next char */ + ldrb w0, [x19], #1 /* Load next char */ cmp w0, 0 beq 2f /* Exit on nul */ bl arm64_lowputc b 1b /* Loop */ 2: - ldp xzr, x30, [sp], #16 + ldp x19, x30, [sp], #16 ret .type boot_stage_puts, %function;