fix(hal): boot aarch64 to the serial console in QEMU virt - #140
Merged
Conversation
The aarch64 _start faulted before reaching Rust: (1) it set SCTLR_EL1.M to enable the MMU without ever installing a TTBR0_EL1 translation table, so the next instruction fetch took a level-1 translation abort; (2) it never enabled FP/SIMD, so the first NEON instruction emitted by Rust codegen (memcpy/formatting) trapped with ESR EC=0x07 and spun in the stub vector table. Fix both in the boot stub: defer the MMU (run with flat physical addressing until an identity page table is built — sufficient for the console + init path) and set CPACR_EL1.FPEN=0b11 before calling kernel_main. The aarch64 kernel now boots in 'qemu-system-aarch64 -M virt' and prints: [ONCRIX/aarch64] Kernel booting... [ONCRIX/aarch64] PL011 UART initialized (115200 8N1) [ONCRIX/aarch64] Heap initialized (16 MiB) x86_64 is unaffected (aarch64-only boot stub).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The aarch64
_startfaulted before reaching Rust:SCTLR_EL1.M(MMU enable) without ever installing aTTBR0_EL1translation table → the next instruction fetch took a level-1 translation abort (ESR 0x86000005, verified viaqemu -d int).Fix both in the boot stub: defer the MMU (flat physical addressing until an identity page table is built — enough for console + init) and set
CPACR_EL1.FPEN=0b11beforekernel_main.Verified —
qemu-system-aarch64 -M virt -cpu cortex-a72 -kernel …now prints:First actual runtime execution of the cross-arch kernel. x86_64 unaffected (aarch64-only boot stub).