This is an automated email from the ASF dual-hosted git repository.

pussuw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new aa5d119bc3 arch/arm64: fix boot stage prints with 
CONFIG_ARCH_EARLY_PRINT=y
aa5d119bc3 is described below

commit aa5d119bc3810f0f664e397a0b8385f6099b95e4
Author: George Poulios <gpoul...@census-labs.com>
AuthorDate: Mon Feb 24 17:28:48 2025 +0200

    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 <gpoul...@census-labs.com>
---
 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 6ddfc55644..7d210d1233 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;

Reply via email to