10 Gbit/s on an old Mellanox ConnectX-3: the driver, the bugs, and what's next
How we wrote a Rust ConnectX-3 driver for nos, got UDP close to line rate, dealt with firmware, queues and MSI-X, and why TCP and NBS still have room to improve.
x86-64 · arm64 · C++20 · Rust
nos is installed straight onto a server and runs virtual machines on it. The network stack, storage, hypervisor and management API are all its own, so there is no other OS underneath. It's written in Rust and C++20 and runs on x86-64 and arm64. Linux and Windows Server VMs run on x86-64 hosts only, for now.
$ ./scripts/qemu-arm64.sh
…
rust_test: passed
SoftIrq: initialized
part: 0 partitions on 1 disks
MountRootFs: mounted ramfs on / (rw)
MountRootFs: mounted procfs on /proc (ro)
tcp: initialized, up to 64 connections
udpshell: started on port 9000
boot: complete
_ _ ___ ____
| \ | |/ _ \/ ___|
| \| | | | \___ \
| |\ | |_| |___) |
|_| \_|\___/|____/
DHCP auto on eth0...
DHCP ip: 10.0.2.15
DNS resolver started, server: 10.0.2.3
$ █nos takes a whole disk of an x86-64 server: a 10 GiB root for the system, and the rest of the disk left empty for virtual machines and storage. Pick the way your hosting provider gives you.
Rescue system
Boot the server into your provider's rescue system, log in over SSH as root and run:
curl -fsSL https://nos-os.tech/install.sh | shA dialog asks which disk to use, how big the root should be and which SSH keys may log in. It offers the server's own network, as the rescue system has it, and the keys root logs in with there. Then it downloads the newest release, checks it against the release's checksums, makes the disk bootable under BIOS and UEFI, and puts nos first in the UEFI boot order, right after network boot. nos's SSH server takes ed25519 keys only.
The same without questions:
curl -fsSL https://nos-os.tech/install.sh | sh -s -- disk /dev/sdX --wipe --network-here --ssh-key /root/.ssh/authorized_keysIf the provider's panel still has the server booting into rescue, switch that back. Then reboot, and about a minute later ssh root@your-server gets you into nos.
ISO
For servers installed from an ISO: mount it as virtual media through IPMI, iDRAC or iLO, or give its link to your provider's install-from-ISO. The same dialog runs on the server's console.
Download the ISOnos-installer-x86_64.iso
Not sure the server suits nos? The menu entry Try nos boots nos straight from the ISO and writes nothing. The screen then shows which disks and network cards nos found.
Your computer
Run nos in QEMU on a laptop in a few minutes, or watch the demo first.
Step by step, with the commands for doing it by hand and for putting nos on a spare partition next to the system already installed: Install nos on a server
Systems software written in older languages like C gets new vulnerabilities all the time, and most of them are memory bugs. To keep that out of nos as far as we can, we chose modern tools from the start.
73% of the code is Rust
Drivers, the network stack, filesystems and the hypervisor are written in Rust. In safe Rust you can't write past the end of an array, use memory after it has been freed, or cause a data race.
0.8% of Rust lines are unsafe
Code marked unsafe, which the compiler can't fully check, is needed only where nos talks to the hardware or to its C++ part. That's under one percent of the Rust, and the hypervisor's logic has just 4 such places in 22,000 lines.
fuzzers and sanitizers
Fuzzers run the kernel's own code on random data, and CI boots both architectures with undefined-behaviour checks on every change. When something breaks, the kernel stops and says where, instead of hanging silently.
We develop in QEMU, run in the cloud and test on real servers. Five of them we can reach only over the network.
We're building a cloud server where nos runs right on the hardware, hosts virtual machines and updates itself without stopping them.
nos boots on real servers, and they can be managed remotely.
New code is written in Rust, with as little unsafe as possible.
A thin layer between the code and the CPU, and the arm64 port. Both were done before the hypervisor.
A Rust hypervisor for VMs on Intel VT-x and AMD-V.
An HTTP API and a web panel to create and delete VMs and reach their consoles.
Update the server's kernel in under 100 ms without stopping its VMs.
How we wrote a Rust ConnectX-3 driver for nos, got UDP close to line rate, dealt with firmware, queues and MSI-X, and why TCP and NBS still have room to improve.
How Windows Server 2022 went from a UEFI shell and failed VM entries to SAC, networking, save/restore and a measured 61% reduction in idle VM exits.
A Linux VM on nos's hypervisor now drives a real NVIDIA GPU with NVIDIA's own driver and runs CUDA at full speed. How it works, what broke on the way, and what's missing.