Replace jump instruction with lla and jr for kernel entry#1170
Conversation
With LTO disabled, a linker error occurs with the j jump instruction.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the RISC-V 64-bit early boot entry jump sequence to avoid linker/relocation range limits when branching to kernel_entry.
Changes:
- Replaced a direct
j {kernel_entry}withlla+jrto avoidR_RISCV_JALrange constraints. - Added explanatory comments documenting the relocation/range rationale.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ZR233 请周老师合并一下 |
There was a problem hiding this comment.
PR #1170 审查结论:APPROVE
修改内容
修改 components/someboot/src/arch/riscv64/entry.rs 中 _head() 裸汇编的早期引导入口:将 j {kernel_entry}(R_RISCV_JAL,范围±1MB)替换为 lla t0, {kernel_entry}; jr t0(auipc+addi+jr,范围±2GB)。
实现逻辑
这是 RISC-V 64 位标准做法:lla 展开为 auipc+addi,利用 PC 相对寻址避免 J 范围限制。.option norvc 保证 32 位编码,code0=8 字节,符合 RISC-V Linux 内核镜像头格式。修改与同文件 kernel_entry() 和 _secondary_entry() 中已有的 lla+jr 模式一致。
CI 状态
自托管 runner 关键测试全部通过:Test axvisor riscv64 qemu / run_host、Test arceos riscv64 qemu / run_host 等。GitHub-hosted 容器 runner 的 Test starry riscv64 qemu / run_container 失败,但 dev 基础分支最近 CI(run 27066722548)也存在相同失败模式,是 pre-existing 环境问题,与本 PR 无关。
重复/重叠分析
无其他 PR 修改 _head() 入口。PR #1160 涉及 someboot 其他文件但不冲突。
阻断项
无阻断项。修改范围小(+4/-2 行),逻辑清晰,与现有模式一致。
Powered by mimo-v2.5-pro
Upstream changes: - feat(starry-kernel): implement io_uring lite (rcore-os#1042) - fix(starry-net): epoll_pwait alignment + netlink MSG_PEEK (rcore-os#921) - Replace jump instruction with lla and jr for kernel entry (rcore-os#1170) Conflicts resolved: - os/StarryOS/kernel/src/syscall/fs/mod.rs: merge io_uring::* export with lock::{release_flock_lock, release_pid_flock_locks} - os/StarryOS/kernel/src/file/mod.rs: fix auto-merge syntax error, add io_uring::IoUring export while preserving our TaskState/Pid imports Validation: - test-nix-prereqs: 12/12 PASSED - syscall (incl. new io_uring/netlink/epoll tests): PASSED - nix app (nosandbox): PASSED
With LTO disabled, a linker error occurs with the j jump instruction.
With LTO disabled, a linker error occurs with the j jump instruction.