This Month in Rust OSDev: September 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.
rust-osdev
Projects
In this section, we give an overview of notable changes to the projects hosted under the rust-osdev
organization.
bootloader
Maintained by @phil-opp, @rybot666, and @64
The bootloader
crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables.
We encountered various boot issues with the new v7.1.0
release of QEMU in September. This also affected downstream projects such as phil-opp/blog_os
and hawkw/mycelium
. After some debugging, we found out that QEMU now reports a new memory region at offset ~1 TiB in the physical memory map, which was much higher than expected by the bootloader crate. As a result, BIOS booting became unusably slow (because of the initial identity mapping) and the automated offset selection for the physical memory map ran into a panic. For full details, see the summary issue.
We fixed the issues in the following way:
- Limit BIOS bootloader's
max_phys_addr
to 4 GiB - Only perform a single TLB flush after identity mapping
- fix
get_free_address
for large sizes (0.10) (published as0.10.13
) - allow allocating more than one level 4 entry (0.9) (published as
0.9.23
)
Thanks to @hawkw and @Freax13 for these contributions!
We also brought the upcoming v0.11
release even closer to the finish line. Thanks to an extensive review of @Freax13, we found and fixed multiple remaining issues. Also thanks to @asensio-project and @TheBotlyNoob for testing the new version and reporting bugs! Some notable changes are:
- Allocate kernel as normal UEFI loader data
- Preserve
RUNTIME_SERVICES_*
memory regions - Update usage instructions and architecture description in README
uefi-rs
Maintained by @GabrielMajeri, @nicholasbishop, and @phip1611
- Add an mdBook
- Read it at https://rust-osdev.github.io/uefi-rs/HEAD/
- More protocol safety improvements
- Implement
HardDriveMediaDevicePath
(along with MBR and GPT tests). - Drop use of unstable try_trait_v2 feature
- "is_regular_file" for file trait + integration test
CStr8
cleanup and enhancements- Transform feature "ignore-logger-errors" to additive feature.
- Release
uefi-macros-0.8.0
,uefi-0.17.0
,uefi-services-0.14.0
- Add
PhysicalAddress
andVirtualAddress
type aliases - Change DevicePath[From|To]Text methods to return a Result
Thanks to @ColinFinck for their contribution!
xhci
Maintained by @toku-sa-n
The xhci
crate provides types of xHCI structures, such as Registers and TRBs.
We merged the following changes in September:
Thanks to @Demindiro for their contribution!
Call for Participation
Want to contribute to a Rust OSDev project, but don't know where to start? Help with one of these outstanding issues!
- (
phil-opp/blog_os
) Looking for a reviewer for a Chinese translation - (
phil-opp/blog_os
) Looking for a reviewer for a Korean translation - (
phil-opp/blog_os
) Looking for a reviewer for a French translation
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.
Other Projects
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.
Theseus OS
(Section written by Kevin Boos (@kevinaboos))
Theseus is a safe-language OS written from scratch in Rust that is in the process of migrating from pure academic research objectives to more general usability and legacy compatibility. As a fully open-source project, we welcome and encourage contributions from everyone!
Since our last update here two months ago, we have worked on the following things:
- Continued our port of Rust
std
to Theseus- Follow our progress in this tracking issue
- Completed: environment variables, RNGs
- In progress: timekeeping, proper virtual filesystem implementation, raw synchronization primitives
- Began adding support for the
aarch64
ARM architecture to Theseus- Still an early work-in-progress
- Redesigned our Local APIC implementation to avoid unnecessary conditionals and panics
- Now the abstraction of functionality across xAPIC and x2APIC is cleaner
- Only disable preemption, not interrupts, during sensitive task management functions
- Introduced a safe abstraction for a preemption-disabling guard type
- Added a preemption-safe
Mutex
andRwLock
implementation - We now use preemption-safe guards for task switching, task lifecycle/cleanup functions, and runqueue management
- Improved task management functions to expediently clean up existed tasks
- Introduced a clear concept of a post-context switch action
- Guarantees that the post-context switch action will always occur, even when switching to a brand new task or switching away from an exited task
- Clarified the ownership of the next task's
TaskRef
during a task switch, ensuring that it is dropped at the right time to avoid delays in its cleanup - Ensured that orphaned tasks are properly reaped via the
JoinableTaskRef
type
- Introduced a clear concept of a post-context switch action
- Avoided using
lazy_static
where possible in favor of plainconst
expressions- Rust's
const_btree_new
nightly feature allowsBTree::new()
to beconst
- Also contributed a PR to the
rangemap
crate such that it can optionally use that new feature- This makes it faster to access and generate TLS data images for new Task creation in Theseus
- Rust's
- Refactored all interrupt handlers into a more conventional design
- Previously, the single
interrupts
crate would statically register device-specific interrupt handlers - Now, each device crate dynamically registers their interrupt handlers with the
interrupts
crate when they initialize themselves - The original design favored explicit dependencies from
interrupts
to<device crate>
for predictable behavior over dynamically-registered states, but causes problems with inverted and cyclic dependencies
- Previously, the single
- Introduced
clippy
CI action and addressed most lint warningsrustfmt
is next, with the hope of standardizing our code base
Check out the Theseus OS blog for the latest details.
phil-opp/blog_os
(Section written by @phil-opp)
We merged the following changes this month:
- Translate post-07 to Japanese
- Copyedit edition 2
paging-introduction/index.md
- Fix typo in french translation
01-freestanding-rust-binary
Thanks to @shimomura1004, @woodyZootopia, @bolded, and @Firenezz for their contributions!
Join Us?
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 Zulip chat.