Skip to content

Commit

Permalink
arch/arm64: fix boot stage prints with CONFIG_ARCH_EARLY_PRINT=y
Browse files Browse the repository at this point in the history
`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 <[email protected]>
  • Loading branch information
gpoulios committed Feb 25, 2025
1 parent 70f070f commit b9191c9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arch/arm64/src/common/arm64_head.S
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b9191c9

Please sign in to comment.