|
| 1 | ++++ |
| 2 | +title = "This Month in Rust OSDev (March 2022)" |
| 3 | +date = 2022-04-07 |
| 4 | + |
| 5 | +[extra] |
| 6 | +month = "March 2022" |
| 7 | +authors = [ |
| 8 | + "phil-opp", |
| 9 | + "GabrielMajeri", |
| 10 | + "josephlr", |
| 11 | + # add yourself here |
| 12 | +] |
| 13 | ++++ |
| 14 | + |
| 15 | +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. |
| 16 | + |
| 17 | +<!-- more --> |
| 18 | + |
| 19 | +This series is openly developed [on GitHub](https://github.com/rust-osdev/homepage/). 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](https://github.com/rust-osdev/homepage/issues/new) or using our [_comment form_](#comment-form) at the bottom of this page. |
| 20 | + |
| 21 | +<!-- |
| 22 | + This is a draft for the upcoming "This Month in Rust OSDev (March 2022)" post. |
| 23 | + Feel free to create pull requests against the `next` branch to add your |
| 24 | + content here. |
| 25 | + Please take a look at the past posts on https://rust-osdev.com/ to see the |
| 26 | + general structure of these posts. |
| 27 | +--> |
| 28 | + |
| 29 | +## Project Updates |
| 30 | + |
| 31 | +In this section, we give an overview of notable changes to the projects hosted under the [`rust-osdev`] organization. |
| 32 | + |
| 33 | +[`rust-osdev`]: https://github.com/rust-osdev/about |
| 34 | + |
| 35 | +### [`x86_64`](https://github.com/rust-osdev/x86_64) |
| 36 | + |
| 37 | +<span class="maintainers">Maintained by [@phil-opp](https://github.com/phil-opp), [@josephlr](https://github.com/orgs/rust-osdev/people/josephlr), [@Freax13](https://github.com/orgs/rust-osdev/people/Freax13), and [@rybot666](https://github.com/orgs/rust-osdev/people/rybot666)</span> |
| 38 | + |
| 39 | +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. |
| 40 | + |
| 41 | +This month, we released version **`0.14.9`** of the `x86_64` crate with lots of improvements: |
| 42 | + |
| 43 | +#### New Features |
| 44 | + |
| 45 | +- [Add `UCet` and `SCet` registers](https://github.com/rust-osdev/x86_64/pull/349) |
| 46 | +- [Specific MSRV now noted in `README`](https://github.com/rust-osdev/x86_64/pull/355) |
| 47 | +- Use [`rustversion`](https://crates.io/crates/rustversion) to [mark certain functions `const fn` on Rust 1.61](https://github.com/rust-osdev/x86_64/pull/353) |
| 48 | +- [`Entry::handler_addr()` is now public](https://github.com/rust-osdev/x86_64/pull/354) |
| 49 | +- [Increase packed structure alignment](https://github.com/rust-osdev/x86_64/pull/362) |
| 50 | +- [Make more address methods `const fn`](https://github.com/rust-osdev/x86_64/pull/369) |
| 51 | + - `VirtAddr::as_ptr()` |
| 52 | + - `VirtAddr::as_mut_ptr()` |
| 53 | + - `PhysAddr::new()` |
| 54 | + - `PhysAddr::try_new()` |
| 55 | + |
| 56 | +_Already merged last month:_ |
| 57 | + |
| 58 | +- [Remove all uses of external assembly](https://github.com/rust-osdev/x86_64/pull/343) |
| 59 | + - `external_asm` and `inline_asm` features are deprecated and now have no effect. |
| 60 | + - `instructions` feature (on by default) now requires Rust 1.59 |
| 61 | +- [Implement `core::iter::Step` for `VirtAddr` and `Page`](https://github.com/rust-osdev/x86_64/pull/342) |
| 62 | + - This trait is only available on nightly. |
| 63 | + - Gated behind `step_trait` feature flag |
| 64 | +- [Address in `VirtAddrNotValid` and `PhysAddrNotValid` is now public](https://github.com/rust-osdev/x86_64/pull/340) |
| 65 | + - [This field now contains the whole invalid address](https://github.com/rust-osdev/x86_64/pull/347) |
| 66 | + |
| 67 | +#### Bug fixes and Documentation |
| 68 | + |
| 69 | +- [Fixed overflow bug in `PageRangeInclusive`](https://github.com/rust-osdev/x86_64/pull/351) |
| 70 | +- [Remove stabilized `const_fn_fn_ptr_basics` and `const_fn_trait_bound` features](https://github.com/rust-osdev/x86_64/pull/352) |
| 71 | +- [Don't set `nomem` in `load_tss`](https://github.com/rust-osdev/x86_64/pull/358) |
| 72 | +- [Correctly initialize TSS's IOPB to be empty](https://github.com/rust-osdev/x86_64/pull/357) |
| 73 | +- [Improve `GlobalDescriptorTable::add_entry` error handling](https://github.com/rust-osdev/x86_64/pull/361)) |
| 74 | +- [Update `tss_segment` documentation](https://github.com/rust-osdev/x86_64/pull/366)) |
| 75 | + |
| 76 | +Thanks to [@jarkkojs](https://github.com/jarkkojs), [@drzewiec](https://github.com/drzewiec), and [@kevinaboos](https://github.com/kevinaboos) for contributing to this release! |
| 77 | + |
| 78 | +#### v0.15 |
| 79 | + |
| 80 | +We also merged some breaking changes which will be published in the upcoming `v0.15` release: |
| 81 | + |
| 82 | +- [Allow the GDT to be of any length](https://github.com/rust-osdev/x86_64/pull/360) |
| 83 | + - [gdt: Check that MAX is in range](https://github.com/rust-osdev/x86_64/pull/365) |
| 84 | +- [`VirtAddr` improvements](https://github.com/rust-osdev/x86_64/pull/370) |
| 85 | +- [Remove `software_interrupt!` macro](https://github.com/rust-osdev/x86_64/pull/363) |
| 86 | +- [Remove usize trait impls](https://github.com/rust-osdev/x86_64/pull/364) |
| 87 | +- [Remove deprecated functions/flags](https://github.com/rust-osdev/x86_64/pull/368) |
| 88 | +- [Update "next" MSRV to 1.59](https://github.com/rust-osdev/x86_64/pull/359) |
| 89 | + |
| 90 | +Special thanks to our co-maintainer [@josephlr](https://github.com/josephlr), who did a lot of great work this month! |
| 91 | + |
| 92 | +### [`uefi-rs`](https://github.com/rust-osdev/uefi-rs) |
| 93 | + |
| 94 | +<span class="maintainers">Maintained by [@GabrielMajeri](https://github.com/GabrielMajeri) and [@nicholasbishop](https://github.com/orgs/rust-osdev/people/nicholasbishop)</span> |
| 95 | + |
| 96 | +The `uefi` crate provides safe and performant wrappers for [UEFI](https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface), the successor to the BIOS. |
| 97 | + |
| 98 | +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](https://github.com/rust-osdev/uefi-rs/issues/360) has been accepted and the corresponding changes [have been merged](https://github.com/rust-osdev/uefi-rs/pull/361) in March: the `Completion` type has been removed and the crate has reverted to using more standard `Result`s everywhere, by treating all warnings as errors. |
| 99 | + |
| 100 | +We merged the following changes in March: |
| 101 | + |
| 102 | +#### New features/protocols |
| 103 | + |
| 104 | +- [Implement the `connect_controller`/`disconnect_controller` methods](https://github.com/rust-osdev/uefi-rs/pull/311) |
| 105 | +- [Implement `BootServices::locate_handle_buffer` function](https://github.com/rust-osdev/uefi-rs/pull/380) |
| 106 | +- [Add rng protocol](https://github.com/rust-osdev/uefi-rs/pull/386) |
| 107 | +- [Add `BootServices::load_image`](https://github.com/rust-osdev/uefi-rs/pull/383) |
| 108 | +- [Add `GptPartitionAttributes` bitflags](https://github.com/rust-osdev/uefi-rs/pull/388) |
| 109 | +- [Add `FileHandle` convenience methods and new file system tests](https://github.com/rust-osdev/uefi-rs/pull/392) |
| 110 | +- [Add `RuntimeServices::query_variable_info`](https://github.com/rust-osdev/uefi-rs/pull/396) |
| 111 | + |
| 112 | +#### Refactorings |
| 113 | + |
| 114 | +- [Make `Error` public](https://github.com/rust-osdev/uefi-rs/pull/382) |
| 115 | +- [Simplify `uefi::Result` type and remove `Completion`](https://github.com/rust-osdev/uefi-rs/pull/361) |
| 116 | +- [Improve `Time` struct](https://github.com/rust-osdev/uefi-rs/pull/395) |
| 117 | + |
| 118 | +#### Bug fixes |
| 119 | + |
| 120 | +- [Fix alignment issues in file info types](https://github.com/rust-osdev/uefi-rs/pull/377) |
| 121 | +- [Update changelog for file info changes](https://github.com/rust-osdev/uefi-rs/pull/373) |
| 122 | +- [Make `LoadedImage`'s load options API safer](https://github.com/rust-osdev/uefi-rs/pull/375) |
| 123 | +- [Fix status to `Result` conversions](https://github.com/rust-osdev/uefi-rs/pull/389) |
| 124 | + |
| 125 | +#### CI & testing |
| 126 | + |
| 127 | +- [Add miri action to `xtask` and CI](https://github.com/rust-osdev/uefi-rs/pull/381) |
| 128 | +- [Don't run doctests with invalid pointers](https://github.com/rust-osdev/uefi-rs/pull/378) |
| 129 | + |
| 130 | +#### Misc & chores |
| 131 | + |
| 132 | +- [Add package sections to changelog](https://github.com/rust-osdev/uefi-rs/pull/385) |
| 133 | +- [Remove some no-longer-needed unstable features](https://github.com/rust-osdev/uefi-rs/pull/387) |
| 134 | +- [Drop maintenance badges from the README](https://github.com/rust-osdev/uefi-rs/pull/393) |
| 135 | +- [Remove no-longer-needed allows for clippy lints](https://github.com/rust-osdev/uefi-rs/pull/394) |
| 136 | +- [Publish new versions of the crates](https://github.com/rust-osdev/uefi-rs/pull/390) |
| 137 | + |
| 138 | +Thanks to [@nicholasbishop](https://github.com/nicholasbishop), [@sven-eliasen](https://github.com/sven-eliasen), [@necauqua](https://github.com/necauqua) and [@AtsukiTak](https://github.com/AtsukiTak) for their contributions! |
| 139 | + |
| 140 | +### [`uart_16550`](https://github.com/rust-osdev/uart_16550) |
| 141 | + |
| 142 | +<span class="maintainers">Maintained by [@phil-opp](https://github.com/phil-opp)</span> |
| 143 | + |
| 144 | +The `uart_16550` crate provides basic support for serial port I/O for 16550-compatible UARTs. We merged the following changes this month: |
| 145 | + |
| 146 | +- [Remove stabilized nightly feature `const_ptr_offset`](https://github.com/rust-osdev/uart_16550/pull/22) <span class="gray">(published as `v0.2.17`)</span> |
| 147 | + |
| 148 | +Thanks to [@tsatke](https://github.com/tsatke) for this contribution! |
| 149 | + |
| 150 | +### [`xhci`](https://github.com/rust-osdev/xhci) |
| 151 | + |
| 152 | +<span class="maintainers">Maintained by [@toku-sa-n](https://github.com/toku-sa-n)</span> |
| 153 | + |
| 154 | +The `xhci` crate provides types of xHCI structures such as Contexts, Extended Capabilities, Registers, and TRBs. This month, we merged some cleanups: |
| 155 | + |
| 156 | +- [fix: clippy warnings](https://github.com/rust-osdev/xhci/pull/130) |
| 157 | +- [ci(deps): enable dependabot](https://github.com/rust-osdev/xhci/pull/129) |
| 158 | + |
| 159 | +## Call for Participation |
| 160 | + |
| 161 | +Want to contribute to a Rust OSDev project, but don't know where to start? Pick up one of these outstanding |
| 162 | +issues in one of our projects and get started! |
| 163 | + |
| 164 | +<!-- |
| 165 | +Please use the following template for adding items: |
| 166 | +- [(`repo_name`) Issue Description](https://example.com/link-to-issue) |
| 167 | +--> |
| 168 | + |
| 169 | +<span class="gray"> |
| 170 | + |
| 171 | +_No tasks were proposed for this section._ |
| 172 | + |
| 173 | +</span> |
| 174 | + |
| 175 | +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](https://github.com/rust-osdev/homepage/pulls) against the `next` branch with the tasks you want to include in the next issue. |
| 176 | + |
| 177 | +## Other Projects |
| 178 | + |
| 179 | +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](https://github.com/rust-osdev/homepage/pulls) with the updates of your OS project for the next post. |
| 180 | + |
| 181 | +### [`phip1611/simple-chunk-allocator`](https://github.com/phip1611/simple-chunk-allocator) |
| 182 | + |
| 183 | +<span class="gray">(Section written by [@phip1611](https://github.com/phip1611))</span> |
| 184 | + |
| 185 | +Philipp Schuster recently released an initial version of his [simple-chunk-allocator](https://github.com/phip1611/simple-chunk-allocator) |
| 186 | +crate. It focuses on being a very simple-to-use general purpose allocator that "just works" for various workloads |
| 187 | +in `no_std` context. A bitmap is used for bookkeeping of used blocks/chunks. This enables a simple algorithm that is easy |
| 188 | +to understand. The allocator uses a combination of the strategies "next fit" and "best fit". It is usable as `#[global_allocator]` |
| 189 | +and operates on static memory, i.e., no paging mechanism involved. The crate is suited to manage the heap inside a kernel |
| 190 | +or in a similar `no_std` application. It is part of the roottask in [Philipp's Diplom (Master) Thesis](https://github.com/phip1611/diplomarbeit-impl) |
| 191 | +where he wrote a runtime system for a Microkernel in Rust. |
| 192 | + |
| 193 | + |
| 194 | +### [`phip1611/linux-libc-auxv`](https://github.com/phip1611/linux-libc-auxv) |
| 195 | + |
| 196 | +<span class="gray">(Section written by [@phip1611](https://github.com/phip1611))</span> |
| 197 | + |
| 198 | +Philipp Schuster recently released an initial version of his [linux-libc-auxv](https://github.com/phip1611/linux-libc-auxv) |
| 199 | +crate. The crate enables the creation and the parsing of the initial Linux stack layout. This layout is a |
| 200 | +special data structure that Linux prepares for applications before they start execution. The C runtime behind the |
| 201 | +`_start` symbol of a libc implementation uses this to find program arguments, environment variables, and the |
| 202 | +auxiliary vector. The layout is tricky to create because the creator must ensure that the layout is valid in the |
| 203 | +address space of the target. However, `linux-libc-auxv` found a way to cope with this. |
| 204 | + |
| 205 | +You can write a "freestanding" binary, i.e., without libc, with this crate, run it under Linux and parse the stack |
| 206 | +layout yourself. This is similar to what the libc does, before Rust's runtime starts, that eventually calls the |
| 207 | +main function of a Rust program. |
| 208 | + |
| 209 | +The crate is part of [Philipp's Diplom (Master) Thesis](https://github.com/phip1611/diplomarbeit-impl) |
| 210 | +where he wrote a runtime system for a Microkernel in Rust that can emulate Linux behaviour and run unmodified |
| 211 | +Linux applications. |
| 212 | + |
| 213 | +### [`phip1611/diplomarbeit-impl`](https://github.com/phip1611/diplomarbeit-impl) |
| 214 | + |
| 215 | +<span class="gray">(Section written by [@phip1611](https://github.com/phip1611))</span> |
| 216 | + |
| 217 | +Philipp Schuster submitted his Diplom (Master) Thesis at TU Dresden where he build a policy-free system-call layer for |
| 218 | +the Hedron microhypervisor. The project comes with a runtime system written in Rust for the microkernel and involves |
| 219 | +a roottask that enables the execution of unmodified Linux binaries through an OS personality/Linux emulation. The |
| 220 | +runtime system covers several interesting aspects of OS development, such as interaction with a kernel, system call |
| 221 | +emulation, and starting programs from ELF files. |
| 222 | + |
| 223 | +### [`phil-opp/blog_os`](https://github.com/phil-opp/blog_os) |
| 224 | + |
| 225 | +<span class="gray">(Section written by [@phil-opp](https://github.com/phil-opp))</span> |
| 226 | + |
| 227 | +We merged a [new Korean translation](https://github.com/JOE1994) of first post of [_Writing an OS in Rust_](https://os.phil-opp.com/) blog this month. Thanks a lot to [@JOE1994](https://github.com/JOE1994) for creating this translation and [@QuqqU](https://github.com/QuqqU) for reviewing it! |
| 228 | + |
| 229 | +We also received lots of smaller fixes, by [@MaxDesiatov](https://github.com/phil-opp/blog_os/pull/1080), [@alaincao](https://github.com/phil-opp/blog_os/pull/1089), [@Programatic](https://github.com/phil-opp/blog_os/pull/1096), [@ruhuang2001](https://github.com/phil-opp/blog_os/pull/1091), [@Hofer-Julian](https://github.com/phil-opp/blog_os/pull/1093), [@SilensAngelusNex](https://github.com/phil-opp/blog_os/pull/1094), and [@julien-me](https://github.com/phil-opp/blog_os/pull/1095). Thank you all for your contributions! |
| 230 | + |
| 231 | +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](https://github.com/bstrie) created a _Major Change Proposal_ to [promote the `x86_64-unknown-none` target to Tier 2](https://github.com/rust-lang/compiler-team/issues/499). 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 `core`/`alloc` crates via `rustup target add`. The great news is that the proposal was already accepted and the [corresponding implementation PR](https://github.com/rust-lang/rust/pull/95705) is ready for review too! |
| 232 | + |
| 233 | +## Join Us? |
| 234 | + |
| 235 | +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](https://gitter.im/rust-osdev/Lobby). |
0 commit comments