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 <gpoulios@census-labs.com>
This commit is contained in:
George Poulios 2025-02-24 17:28:48 +02:00 committed by Ville Juven
parent c7702894fe
commit aa5d119bc3

View file

@ -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;