Code Monkey home page Code Monkey logo

kerla's Introduction

Kerla

CI

screenshot

Kerla is a monolithic operating system kernel from scratch in Rust which aims to be compatible with the Linux ABI, that is, runs Linux binaries without any modifications.

  • Implements *NIX process concepts: context switching, signals, fork(2), execve(2), wait4(2), etc.
  • Supports commonly used system calls like write(2), stat(2), mmap(2), pipe(2), poll(2), ...
  • No disk support for now: initramfs is mounted as the root file system.
  • Pseudo file systems: tmpfs and devfs.
  • smoltcp-based TCP/IP support.
  • Implements tty and pseudo terminal (pty).
  • Supports QEMU and Firecracker (with virtio-net device driver).
  • Supports x86_64.
  • Docker-based initramfs build system.

Check out my blog post for motivation and my thoughts on writing an OS kernel in Rust.

Demo: SSH into Kerla!

You can play with Kerla over ssh. Your login is not visible from others (except me): we automatically launch a dedicated microVM on Firecracker for each TCP connection.

If you found bugs or missing features, let me know on GitHub issues :)

Running a Docker Image (experimental)

You can run a Docker image as a root file system (not as a container!) on Kerla Kenrel instead of our initramfs built from initramfs directory.

For example, to run nuta/helloworld image (Dockerfile), try the following command:

$ make IMAGE=nuta/helloworld run
...
[   0.029] syscall: execve(439398, 4393b8, 4393c8, 8, 2f2f2f2f2f2f2f2f, 8080808080808080)
[   0.030] syscall: arch_prctl(1002, 4055d8, 0, 20000, 0, ff)
[   0.031] syscall: set_tid_address(4057f0, 4055d8, 0, 20000, 0, ff)
[   0.033] syscall: ioctl(1, 5413, 9ffffeed0, 1, 405040, 9ffffeef7)

 _          _ _                            _     _ _
| |__   ___| | | ___   __      _____  _ __| | __| | |
| '_ \ / _ \ | |/ _ \  \ \ /\ / / _ \| '__| |/ _` | |
| | | |  __/ | | (_) |  \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___/    \_/\_/ \___/|_|  |_|\__,_(_)

This feature is in the very early stage and I guess almost all images out there won't work because:

  • They tend to be too large to be embedded into the kernel image.
  • They might use unimplemented features (e.g. position-independent executables used in Alpine Linux).

Building and Running the OS

See HACKING.md for instructions on building from source, running on emulators, etc.

Compatibility

See COMPATIBILITY.md for the current status.

Contributing

Send me bug reports, feature requests, and patches on GitHub for example:

  • Implementing missing features: majority of existing Linux applications won't work due to the lack of features.
  • Writing documentation: I think Kerla could be good material to learn how operating system kernel works.
  • Trying experimenting with Rust-y ideas: for example currently I'm interested in GhostCell.

License

See LICENSE.md.

Related Work

Emulating Linux ABI is not a novel work. Some UNIX-like kernels like FreeBSD and NetBSD already have their own Linux emulation layers. Windows has a well-known feature called Windows Subsystem for Linux (WSL) which enables running Linux binaries seamlessly. WSL 1 implements the feature by the ABI emulation. WSL 2 runs the real Linux kernel using the hardware-accelerated virtualization (Hyper-V) by the way.

Aside from general-purpose operating systems, there're some attractive projects related to the Linux ABI emualtion. OSv is a unikernel which runs unmodified Linux binaries. rCore is a teaching operating system which implements the Linux ABI in Rust. Noah suggests an intriguing approach to run unmodified Linux binaries on macOS.

kerla's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.