arch/arm64: fix boot stage prints with CONFIG_ARCH_EARLY_PRINT=y #15901
+4
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
boot_stage_puts
used by early assembly head, callsarm64_lowputc()
for each character of the string to be printed in a loop. During that loop it usesx1
as the pointer to the next character to be printed. However,x1
is clobbered[1] byarm64_lowputc()
, resulting in undefined behaviour (only the first character of the string is guaranteed to be printed).Fix this by using
x9
instead. Despitex9
not currently being used by any other instruction in arm64_head.S, save it on entry, and restore it on exit.[1] Observed clobbering behaviour with
arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64
.Impact
The change does not affect users, build processes, hardware, documentation or security compatibility.
The only notable effect should be the early console messages in arm64 builds being fully (and more reliably) visible when configured with
CONFIG_ARCH_EARLY_PRINT=y
.Testing
arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64
imx93evk:nsh
CONFIG_ARCH_EARLY_PRINT=y
WIthout the change, early boot stage messages would appear as:
With the change, early boot stage messages are: