fix(loongarch): LoongArch 用户态 bringup + rootfs 工具链整理,并补齐 statx 修复 busybox ls#236
Conversation
- 启动入口:探测 DTB 指针并写入 DTP,提升设备树初始化稳定性
- trap:修正 trap_entry/__restore 寄存器保存/恢复映射,避免用户态寄存器被污染
- tlb refill:使用 lddir/ldpte/tlbfill 实现 refill 入口,仅用 TLBRSAVE 保存 t0,避免踩
CSR
- execve:启用 EUEN.FPE;用户栈顶预留 TLS 页并设置 tp,适配 musl/busybox
- 任务/调度:init 固定 PID/TID=1;CPU0 补齐 idle_task 兜底,避免 runqueue 为空时 panic
- 挂载流程:LoongArch 与 RISC-V 对齐,/dev 等由 rcS 挂载;sys_mount 对 /dev,/proc,/
sys,/tmp 自动创建挂载点目录,/dev 挂载后 init_dev 创建设备节点
- 文档:新增 LoongArch bringup 修复总结并加入 SUMMARY
Summary of ChangesHello @ZIYAN137, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此 PR 旨在将 fix/la-interrupt 分支合并回 main,核心工作是为 LoongArch 架构实现全面的用户态启动支持,解决 BusyBox ls 命令在 LoongArch 上因缺少 statx(2) 系统调用而无法正常运行的关键问题,并对 LoongArch 的根文件系统结构和构建工具链进行了整理与优化,以提升其稳定性和可用性。 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
本 PR 是一项重大的贡献,为 LoongArch 架构带来了用户态支持,并修复了 busybox ls 的关键问题。改动范围广泛,涵盖了从启动流程、异常处理到系统调用实现和工具链调整的方方面面。bringup_userland.md 中详尽的文档尤其值得称赞,它清晰地解释了问题、解决方案和验证步骤。
我的审查主要基于所提供的文件。由于提供的差异信息有限,我的审查集中在 scripts/make_init_simple_fs.py 工具上。我发现了一些通过重构文件收集和过滤逻辑来提高其效率和可维护性的机会。建议的更改整合了逻辑,消除了冗余,并通过避免多次遍历文件系统来提高性能。
总体而言,这是一个高质量的 PR,它使操作系统更加健壮和可移植。
fix(loongarch): LoongArch 用户态 bringup + rootfs 工具链整理,并补齐 statx 修复 busybox ls
fix(loongarch): LoongArch 用户态 bringup + rootfs 工具链整理,并补齐 statx 修复 busybox ls
fix(loongarch): LoongArch 用户态 bringup + rootfs 工具链整理,并补齐 statx 修复 busybox ls
🐞 Bug Fix / 错误修复
🐛 描述 (Description)
本 PR 用于将当前分支(
fix/la-interrupt)合并回main,包含 LoongArch 用户态 bringup、rootfs/构建工具链整理,以及补齐statx(2)以修复 BusyBoxls在 LoongArch 下报ENOSYS的问题。其中与 Issue #234 直接相关的现象是:在 LoongArch 运行到用户态 BusyBox shell 后,执行
ls会报:根因是用户态调用了
statx(2)(syscall id=291),内核返回ENOSYS,BusyBox 将其表现为 “Function not implemented”。本 PR 补齐statx系统调用,并在 VFS/UAPI 层补齐必要的数据结构与转换,使ls等依赖statx的命令在 LoongArch 上可正常工作。除此之外,本分支还包含 LoongArch 启动入口/异常处理/TLB refill/execve/TLS/挂载流程等对齐修复,以及 rootfs 目录结构整理与相关文档补齐。
📦 本分支相较 main 的改动概览 (Compared to
main)eca86a9loongarch: task switch and rootfs toolingb150890Merge remote-tracking branch 'upstream/main' into feat/interrupt-user12e08bccargo fmt5ca161ffixd8ed6fafix:修复一些定义错误,使用错误baa80b7bug定位968ff94fix(loongarch): 修复用户态启动并对齐启动流程9765dacchore(loongarch): 降级 bringup 调试输出cd5669bMerge remote-tracking branch 'origin/main' into fix/la-interrupt2e13235fix: 加入LoongArch的ELF解析e41e864fix: 移动lib2615014refactor: 重整data/loongarch_musl/9fe527cfix(loongarch): 补齐 statx,修复 busybox ls “Function not implemented”📊 Diff Stats
865files changed,1993insertions(+),186deletions(-)✅ 修复内容 (What Changed)
(按模块归纳,覆盖本分支相对
main的改动范围)LoongArch bringup
trap_entry/__restore寄存器保存/恢复映射,降低用户态寄存器污染与 trap storm 风险syscall / Linux ABI
statx(2):增加SYS_STATX = 291(loongarch/riscv),并在 syscall 分发中接入(按 syscall number 递增顺序排列)sys_statx:内核实现statx(dirfd, pathname, flags, mask, buf),返回STATX_BASIC_STATS(目前忽略mask的细粒度筛选)ENOSYSrootfs / tooling / docs
data/loongarch_musl目录结构并补齐 BusyBox 用户态文件document/SUMMARY.md🚨 重现步骤 (Steps to Reproduce)
make build ARCH=loongarchmake run ARCH=loongarch/ #交互 shell 后执行ls/bin/sh: ls: Function not implemented🔗 关联 Issue
Fixes #234
🧪 测试 (Testing)
cargo build --target loongarch64-unknown-none(可编译)cargo build --target riscv64gc-unknown-none-elf(可编译)/ #后执行ls可正常工作(不再报 “Function not implemented”)