Rust OSDev Operating System Development in Rust

This Month in Rust OSDev (May 2020)

Welcome to the second issue of "This Month in Rust OSDev". In these posts, we will 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.

Project Updates

In this section, we give an overview of notable changes to the projects hosted under the rust-osdev organization.

x86_64

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.

In May, the crate received a bugfix for inclusive page/frame ranges. We also landed a long-awaited change to the Mapper::map_to function to set certain page table flags also in higher level page tables:

Thanks to @haraldh and @mrll for their contributions!

cargo-xbuild

The cargo-xbuild project provides cargo command wrappers to cross-compile the sysroot crates core and alloc.

This month, rustc/cargo changed their codegen behavior for builds with link-time optimization (LTO), which lead to breakage for LTO builds with cargo-xbuild. Fixing this issue was not easy and required multiple tries until we found a proper solution.

Unfortunately, the solution still led to link issues for some people, which was caused by a bug in cargo/rustc. Thanks to @alexcrichton, this was quickly fixed in rustc, so that now everything should work again.

Apart from these bugfixes, there were also two other changes this month:

Thanks to @Nils-TUD for their contribution and to all the people that helped investigating the build errors!

acpi

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.

Not a lot happened this month, but preparations were made to change how the AML namespace is stored on the heap, in order to avoid a lot of small heap allocations for AML paths, and reduce the number of heap allocations overall. However, some more profiling infrastructure will need to be built before starting this.

In preparation, a change to how DefNames are stored in the namespace was made, which avoids an extra heap allocation per DefName, and also allows us to simplify some code around the aml crate.

bootloader

The bootloader crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables. It received the following updates this month:

Thanks to @mark-i-m and @Aaron1011 for their contributions!

bootimage

The bootimage tool allows the creation of bootable disk images for bootloader-based kernels. It also provides a runner executable for cargo to make cargo xrun and cargo xtest work using QEMU. In May, the crate was almost completely rewritten with a smaller API to make it more maintainable:

uart_16550

The uart_16550 crate provides basic support for serial port I/O for 16550-compatible UARTs. This month, the crate received the following updates:

Thanks to @dbeckwith for their contribution!

uefi

The uefi crate provides abstractions for the UEFI standard that replaces the traditional BIOS on modern systems. This month, the crate's dependencies were updated, and a bug was fixed in the graphics protocol:

Thanks to @imtsuki and @BinaryTENSHi for their contributions!

Personal Projects

In this section, we describe updates to personal 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.

IsaacWoods/pebble

(Section written by @IsaacWoods)

This month, I've been tracking down a bug in the kernel that causes usermode stacks to become corrupted on the return of some system calls. While I've not found the root cause, I've taken this opportunity to add some more debugging capabilities, which have found a number of other kernel bugs.

I also started working on the Rust implementation of Ptah, the wire format for Pebble's message passing interface. It allows libraries to easily use Serde to serialize and deserialize Rust types to and from the wire format. In the future, a compiler will be able to generate bindings for Ptah for a number of different supported languages, which will allow tasks written in different languages to communicate over Pebble Channels using idiomatic types.

RustyHermit

(Section written by @stlankes)

RustyHermit is a unikernel targeting a scalable and predictable runtime. Unikernel means, you bundle your application directly with the kernel library, so that it can run without any installed operating system. This reduces image size and overhead, therefore, interesting applications include virtual machines and high-performance computing.

This month the integration of smoltcp has been improved and first support for virtio has been integrated. The integration in Rust's standard runtime is already in progress and clients can be developed with TcpStream. Server side applications will follow soon.

phil-opp/blog_os

(Section written by @phil-opp)

This month, support for the legacy asm! macro was removed from rustc. This lead to build errors for the Writing an OS in Rust project because some dependencies were still using the macro. To fix this, I landed a number of dependency updates:

I also decided to change the design of the executor in the Async/Await post to simplify it:

While I already started a draft on the next blog post about processes, I currently plan to look into adding UEFI support to the bootloader crate first. The reason is that UEFI support will require some fundamental changes to the blog because the VGA text buffer and the legacy PIC are not supported on UEFI. This is also relevant to the upcoming post about processes, since different designs would be possible if we used the APIC instead of the legacy PIC. It therefore makes most sense to me to sort this out first.

rust-embedded/rust-raspberrypi-OS-tutorials

(Section written by @andre-richter)

May was a quiet month for the project, since I am currently taking a little hiatus. I am planning to restart working on new content two or three months down the road.

Therefore, only some maintenance updates went in, e.g. bumping all dependency crates to versions that support the new llvm_asm! macros. Also, the :cn: chinese translations received updates/additions (main Readme; 00_before_we_start).

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.

Comments