This Month in Rust OSDev: March 2022
Welcome to a new issue of "This Month in Rust OSDev". In these posts, we give a regular overview of notable changes in the Rust operating system development ecosystem.
This series is openly developed on GitHub. Feel free to open pull requests there with content you would like to see in the next issue. If you find some issues on this page, please report them by creating an issue or using our comment form at the bottom of this page.
In this section, we give an overview of notable changes to the projects hosted under the
x86_64 crate provides various abstractions for
x86_64 systems, including wrappers for CPU instructions, access to processor-specific registers, and abstraction types for architecture-specific structures such as page tables and descriptor tables.
This month, we released version
0.14.9 of the
x86_64 crate with lots of improvements:
- Specific MSRV now noted in
rustversionto mark certain functions
const fnon Rust 1.61
Entry::handler_addr()is now public
- Increase packed structure alignment
- Make more address methods
Already merged last month:
- Remove all uses of external assembly
inline_asmfeatures are deprecated and now have no effect.
instructionsfeature (on by default) now requires Rust 1.59
- This trait is only available on nightly.
- Gated behind
- Address in
PhysAddrNotValidis now public
Bug fixes and Documentation
- Fixed overflow bug in
- Remove stabilized
- Don't set
- Correctly initialize TSS's IOPB to be empty
We also merged some breaking changes which will be published in the upcoming
- Allow the GDT to be of any length
- Remove usize trait impls
- Remove deprecated functions/flags
- Update "next" MSRV to 1.59
Special thanks to our co-maintainer @josephlr, who did a lot of great work this month!
uefi crate provides safe and performant wrappers for UEFI, the successor to the BIOS.
One of the pain points of developers building software using
uefi-rs has been the
Completion type, which is like an expanded
Result type which also handles warnings (besides successes and errors). The RFC for the removal of the
Completion type has been accepted and the corresponding changes have been merged in March: the
Completion type has been removed and the crate has reverted to using more standard
Results everywhere, by treating all warnings as errors.
We merged the following changes in March:
- Implement the
- Add rng protocol
FileHandleconvenience methods and new file system tests
- Fix alignment issues in file info types
- Update changelog for file info changes
LoadedImage's load options API safer
- Fix status to
CI & testing
Misc & chores
- Add package sections to changelog
- Remove some no-longer-needed unstable features
- Drop maintenance badges from the README
- Remove no-longer-needed allows for clippy lints
- Publish new versions of the crates
Maintained by @phil-opp
uart_16550 crate provides basic support for serial port I/O for 16550-compatible UARTs. We merged the following changes this month:
- Remove stabilized nightly feature
Thanks to @tsatke for this contribution!
Maintained by @toku-sa-n
xhci crate provides types of xHCI structures such as Contexts, Extended Capabilities, Registers, and TRBs. This month, we merged some cleanups:
Call for Participation
Want to contribute to a Rust OSDev project, but don't know where to start? Pick up one of these outstanding issues in one of our projects and get started!
No tasks were proposed for this section.
If you maintain a Rust project related to operating system development and are looking for contributors, especially for tasks suited to people getting started in this space, please create a PR against the
next branch with the tasks you want to include in the next issue.
In this section, we describe updates to Rust OS projects that are not directly related to the
rust-osdev organization. Feel free to create a pull request with the updates of your OS project for the next post.
(Section written by @phip1611)
Philipp Schuster recently released an initial version of his simple-chunk-allocator
crate. It focuses on being a very simple-to-use general purpose allocator that "just works" for various workloads
no_std context. A bitmap is used for bookkeeping of used blocks/chunks. This enables a simple algorithm that is easy
to understand. The allocator uses a combination of the strategies "next fit" and "best fit". It is usable as
and operates on static memory, i.e., no paging mechanism involved. The crate is suited to manage the heap inside a kernel
or in a similar
no_std application. It is part of the roottask in Philipp's Diplom (Master) Thesis
where he wrote a runtime system for a Microkernel in Rust.
(Section written by @phip1611)
Philipp Schuster recently released an initial version of his linux-libc-auxv
crate. The crate enables the creation and the parsing of the initial Linux stack layout. This layout is a
special data structure that Linux prepares for applications before they start execution. The C runtime behind the
_start symbol of a libc implementation uses this to find program arguments, environment variables, and the
auxiliary vector. The layout is tricky to create because the creator must ensure that the layout is valid in the
address space of the target. However,
linux-libc-auxv found a way to cope with this.
You can write a "freestanding" binary, i.e., without libc, with this crate, run it under Linux and parse the stack layout yourself. This is similar to what the libc does, before Rust's runtime starts, that eventually calls the main function of a Rust program.
The crate is part of Philipp's Diplom (Master) Thesis where he wrote a runtime system for a Microkernel in Rust that can emulate Linux behaviour and run unmodified Linux applications.
(Section written by @phip1611)
Philipp Schuster submitted his Diplom (Master) Thesis at TU Dresden where he build a policy-free system-call layer for the Hedron microhypervisor. The project comes with a runtime system written in Rust for the microkernel and involves a roottask that enables the execution of unmodified Linux binaries through an OS personality/Linux emulation. The runtime system covers several interesting aspects of OS development, such as interaction with a kernel, system call emulation, and starting programs from ELF files.
(Section written by @phil-opp)
Unfortunately I didn't have time to work on the new version of the
bootloader crate for the upcoming third edition of the blog this month. However, there was some surprising development on the Rust side that should help us with the new build system: @bstrie created a Major Change Proposal to promote the
x86_64-unknown-none target to Tier 2. This is a bare-metal target that should be compatible with our kernel, so we might not need
-Zbuild-std anymore in the future. Instead, we could download a precompiled version of the
alloc crates via
rustup target add. The great news is that the proposal was already accepted and the corresponding implementation PR is ready for review too!
Are you interested in Rust-based operating system development? Our
rust-osdev organization is always open to new members and new projects. Just let us know if you want to join! A good way for getting in touch is our gitter channel.