-
Notifications
You must be signed in to change notification settings - Fork 37
Proposal: Integrate arceos_posix_api into this repository to enhance maintainability #16
Description
Background
I was trying to implement a few system calls and found that we now have a messy split between starry-next and arceos_posix_api.
Let's say, ppoll. I wanted to implement it in arceos_posix_api at first, because this crate already has similar functions such as select and epoll. But then I noticed that ppoll also needs to handle signals. Although we don't have a signal mechanism now, if we are going to implement it in starry-next in the future, then ppoll is best implemented in starry-next (or even only here). Also note that since select is implemented in arceos_posix_api, it would be tricky to implement pselect later.
Proposal
Currently, we have some syscalls that are proxied to arceos_posix_api functions, mainly file system related parts. This causes some maintenance inconveniences, for example, some syscalls depend on our TaskExt, others require the internal structure of arceos_posix_api, and some may require both. As a result, when implementing new features, you may need to modify both upstream and downstream repositories simultaneously.
My proposal is that we no longer rely on the arceos_posix_api crate, and maintain a separate syscall interface crate in this repository. This does not mean a complete rewrite, the existing code in arceos_posix_api can be ported and improved, and then other functions implemented for the monolithic kernel can be added.
Benefits
- More convenient development - Single source for syscall implementations, developing in a single repository
- Reduce duplication of functionality - We now repeat the same interface as
arceos_posix_apiinstarry-next. - More secure - Although we have
UserPtrto check the safety of the user address, the raw pointer is still passed to the implementation instead of the safe Rust-style wrapper. And for the case ofwritevwith nested pointers, we currently do not check it.
Implementation details
No changes to upstream repositories are required. We can divide starry-next into the following three crates:
starry-core: mainly contains the currentmm.rs,ptr.rsandtask.rs, providing core functionality in the monolithic kernelstarry-api: the currentsyscall_impmodule merged witharceos_posix_api, wherearceos_posix_apican enjoy the convenience brought bysyscall_instrumentorUserPtrwhen portingstarry(already exists): entrymain.rsand syscall handlerhandle_syscall
Thoughts
This is just a preliminary idea and may have some imperfections, so discussion and suggestions are welcome. Even if this proposal is not adopted, I still strongly recommend that we at least solve this issue to reduce the pain of future development.