The Kerla project develops a Linux-compatible kernel in Rust

The Kerla project is developing an operating system kernel written in Rust. The new kernel is designed from the ground up to be compatible with the Linux kernel at the ABI level, which will allow unmodified executables built for Linux to run in a Kerla-based environment. The code is distributed under the Apache 2.0 and MIT licenses. The project is being developed by Japanese developer Seiya Nuta, known for creating the Resea microkernel operating system written in C.

At the current stage of development, Kerla can only run on x86_64 systems and implements basic system calls such as write, stat, mmap, pipe, and poll, supports signals, unnamed pipes, and context switches. For process management, calls such as fork, wait4, and execve are provided. There is support for tty and pseudo-terminals (pty). Of the file systems, initramfs (used to mount the root FS), tmpfs and devfs are still supported. A network stack is provided with support for TCP and UDP sockets, implemented on the basis of the smoltcp library.

The developer has prepared a bootable environment that runs in QEMU or in the Firecracker virtual machine with the virtio-net driver, to which you can already connect via SSH. Musl is used as a system library, and BusyBox is used as user utilities.

The Kerla project develops a Linux-compatible kernel in Rust

Based on Docker, a build system has been prepared that allows you to create your own boot initramfs with the Kerla core. The fish-like nsh shell and the Kazari GUI stack based on the Wayland protocol are being developed separately.

The Kerla project develops a Linux-compatible kernel in Rust

Using the Rust language in a project reduces the number of bugs in the code by applying safe coding techniques and improving the efficiency of identifying problems when working with memory. Memory safety is provided in Rust at compile time through reference checking, keeping track of object ownership and object lifetime (scope), as well as through evaluation of the correctness of memory access during code execution. In addition, Rust provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors, and simplifies input value processing through pattern matching facilities. .

For the development of low-level components, such as the OS kernel, Rust provides support for raw pointers, structure packing, assembler inline inserts, and assembler file inlining. To work without being tied to the standard library, there are separate crate packages for performing operations on strings, vectors, and bit flags. Among the advantages, there are also built-in tools for assessing code quality (linter, rust-analyzer) and creating unit tests that can be run not only on real hardware, but also in QEMU.

Source: opennet.ru

Add a comment