Writing an OS in Rust (Second Edition)

Philipp Oppermann's blog

Updates in August 2019

This post gives an overview of the recent updates to the Writing an OS in Rust blog and the used libraries and tools.

I was very busy with finishing my master's thesis, so I didn't have any to implement any notable changes myself. Thanks to contributions by @vinaychandra and @64, we were still able to publish new versions of the x86_64, bootimage and bootloader crates.

blog_os

Apart from rewriting the section about no-harness tests of the Testing post, there were no notable changes to the blog in August. Now that I have some more free time again, I plan to upgrade the blog to the latest versions of bootloader and bootimage, evaluate the use of GitHub Actions for the repository, and continue the work on the upcoming post about heap allocator implementations.

x86_64

Thanks to @vinaychandra, the x86_64 crate now has support for the FsBase and GsBase registers. The change was published as version 0.7.5.

bootimage

To allow bootloaders to read configuration from the Cargo.toml file of the kernel, the bootimage crate now passes the location of the kernel's Cargo.toml to bootloader crates. This change was implemented by @64 and published as version 0.7.7.

bootloader

Apart from initializing the CPU and loading the kernel, the bootloader crate is also responsible for creating several memory regions for the kernel, for example a program stack and the boot information struct. These regions must be mapped at some address in the virtual address space.

As a stop-gap solution, the bootloader crate used fixed virtual addresses for these regions, which resulted in errors if the kernel tried to use the same address ranges itself. For example, the (optional) recursive mapping of page tables often conflicted with so-called higher half kernels, which live at the upper end of the address space. To avoid these conflicts, @64 updated the bootloader crate to dynamically map the kernel stack, boot info, physical memory, and recursive table regions at an unused virtual address range.

To also support specifying explicit addresses for these regions, @64 further added support for parsing bootloader configuration from the kernel's Cargo.toml. This way, the virtual addresses of the kernel stack and physical memory mapping can now be configured using a package.metadata.bootloader key in the Cargo.toml of the kernel. In a third pull request, @64 also made the kernel stack size configurable.

The changes were published together as version 0.8.0. This is a breaking update because the new configuration system requires at least version 0.7.7 of bootimage, which is the first version that passes the location of the kernel's Cargo.toml file.

Thank You!

I want to thank all the people who support me on GitHub, Patreon, and Donorbox. It means a lot to me!



Comments