This Month in Rust OSDev: January 2024
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.
Announcements, News, and Blog Posts
Here we collect news, blog posts, etc. related to OS development in Rust.
- This Month in Redox
- x86 Kernel Development & Relocatable Binaries – What I learned about Toolchains and Relocatable Code
- This post is roughly a summary of the obscure knowledge Philipp learned about toolchains and relocatable code in the last couple of years with a focus on relocatable x86_64 multiboot2 kernels for legacy BIOS boot.
- The Embedded Rustacean Issue 11 and Issue 12
- FOSDEM 2024
- Making an RISC-V OS (Part 1): Project Setup
- Looking for people to help out with CharlotteOS (Beginners are welcome!)
- The Linux kernel now contains the first useful component written in Rust
- BPF Opens Door to Linux Extensible Scheduling (Maybe with Rust!)
Infrastructure and Tooling
In this section, we collect recent updates to rustc
, cargo
, and other tooling that are relevant to Rust OS development.
- Stabilize single-field offset_of
- LLVM 18 x86 data layout update
- cargo: Strip debuginfo when debuginfo is not requested
rust-osdev
Projects
In this section, we give an overview of notable changes to the projects hosted under the rust-osdev
organization.
x86_64
Maintained by @phil-opp, @josephlr, and @Freax13
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.
We merged the following PR this month:
We also merged the following changes into the next
branch, which will be released as v0.15
soon:
- Update
next
branch with latest changes frommaster
- remove deprecated from_bits_unchecked functions
- make
HandlerFuncType
unsafe - Update docs to clarify new
set_handler_fn
behavior
bootloader
Maintained by @phil-opp
The bootloader
crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables. This month, we merged the following nightly fixes:
- Fix data layout for stage 3 target
- Release
v0.11.6
- [v0.9] Fix data layout for
x86_64-bootloader
target- Released as v0.9.24
acpi
Maintained by @IsaacWoods
The acpi
repository contains crates for parsing the ACPI tables – data structures that the firmware of modern computers use to relay information about the hardware to the OS. We merged the following changes this month:
Thanks to @Spartan2909 for their contribution!
uefi-rs
Maintained by @GabrielMajeri, @nicholasbishop, and @phip1611
The uefi-rs
crate provides safe and performant wrappers for UEFI, the successor to the BIOS. We merged the following PRs this month:
- Fix broken UEFI spec link in uefi-raw README.md
- book: Add a page on building drivers
- book: Add a link to rust's UEFI target docs
- uefi-raw: Add LoadFileProtocol and LoadFile2Protocol
Thanks to @gurry for their contribution!
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.
phip1611/phipsboot
(Section written by @phip1611)
I'd like to announce my project PhipsBoot. 🎉 PhipsBoot is a relocatable x86_64 bootloader for legacy x86_64 boot written in Rust and assembly. It is intended to be loaded by GRUB via Multiboot2, where it uncovers its main benefit: It is relocatable in physical memory without having relocation information in the ELF! It outsources a lot of complexity to GRUB which also better fits into the ecosystem and makes it easier usable. The README contains more background about why I have chosen to use GRUB instead of writing my own stage 1 bootloader.
This project combines a lot of toolchain and binary knowledge and experience I collected and gained in recent years about legacy x86_64 boot. The main contribution IMHO is how the binary is assembled and that the thing boots with all the properties described in the README, but not the high-level functionality itself.
I am especially proud of the well-commented structure of the assembly files. For example the whole page-table mappings are done IMHO very nicely even tho it is assembly language. Also, I think it turned out quite cool how I configured the linker script. I hope this can be a learning resource for others!
TL;DR: It is a learning ground and a reference for how to solve the relocation problem with Multiboot2 and GRUB, as GRUB is not able to load DYN ELFs.
You have multiple options for testing it out:
$ cloud-hypervisor --debug-console file=log.txt --kernel ./build/phipsboot.elf64
(using Xen PVH)$ qemu-system-x86_64 -kernel ./build/phipsboot.elf32 -debugcon stdio
(using Multiboot 1)
phil-opp/blog_os
(Section written by @phil-opp)
We merged the following changes to the Writing an OS in Rust blog this month:
- Update data layouts in target specifications
- change some format errors for chinese edition minimal kernel
- fix testing and paging introduction chapter errors in zh-CN translation
- [Edition 3] fix a lil typo
- [Edition 3] Fix typos in code for
embedded_graphics
crate in chapter 3 - [Edition 3] Fix embedded_graphics code + typo in chapter 3
- [Edition 3] Fix typo in chapter 2
- [Edition 3] Fix formatting in chapter 2
Thanks to @acyanbird, @proudmuslim-dev, and @lachsdachs 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.