Fourth edition of patches for the Linux kernel with support for the Rust language

Miguel Ojeda, author of the Rust-for-Linux project, has proposed a fourth option for components for Rust device driver development for Linux kernel developers to consider. Rust support is considered experimental, but has already been agreed to be included in the linux-next branch and is mature enough to start working on abstraction layers over kernel subsystems, as well as writing drivers and modules. The development is funded by Google and the ISRG (Internet Security Research Group), which is the founder of the Let's Encrypt project and promotes HTTPS and the development of technologies to increase the security of the Internet.

Recall that the proposed changes make it possible to use Rust as a second language for developing drivers and kernel modules. Rust support is presented as an option that is not enabled by default and does not result in the inclusion of Rust among the required build dependencies for the kernel. Using Rust to develop drivers will allow you to create safer and better drivers with minimal effort, free from problems such as accessing a memory area after it is freed, dereferencing null pointers, and buffer overruns.

Memory-safe handling 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. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

The new version of the patches continues to eliminate the comments made during the discussion of the first, second and third editions of the patches. In the new version:

  • Transitioned to use the stable release of Rust 1.58.0 as the reference compiler. Among the changes needed for the project, which are not yet included in the main Rust toolkit, are the "-Zsymbol-mangling-version=v0" flag (expected in Rust 1.59.0) and the "maybe_uninit_extra" mode (expected in Rust 1.60.0) .
  • Added automatic checks for the availability of suitable Rust tooling and expanded the ability to test Rust support in the system.
  • New abstractions are proposed for accessing device identifier tables (“IdArray” and “IdTable”) from Rust code.
  • Added layers for calling functions related to the timer (clock framework).
  • Platform drivers are now defined through trait implementations.
  • A new macro has been added to simplify the registration of platform drivers, and a new Generic Driver template has been proposed.
  • Added macros for "dev_*" structures.
  • Added "{read,write}*_relaxed" methods for IoMem type .
  • Removed the FileOpener property to simplify file operations.
  • The "ThisModule" parameter has been added to the number of arguments passed during driver registration.
  • A typical template for creating kernel modules in the Rust language is proposed.

Source: opennet.ru

Add a comment