When a developer says they put a language model "in Ring -1, below Linux," they are talking about CPU privilege levels: the hardware rules that decide which software may touch what. These rules explain why an app crash closes one window, why a kernel crash takes down the whole machine, and how one server can run dozens of operating systems at once.

This explainer covers the ideas behind Ring -1 Kernel Surgeon, the hypervisor that runs a 2B model underneath Linux.

4
Privilege rings defined by x86 (0 to 3)
Wikipedia
2
Rings Linux, macOS and Windows actually use
Wikipedia
2005–06
When Intel and AMD added hardware virtualization
Wikipedia

What is a privilege ring?

A ring is a level of trust the CPU enforces. Code in an inner ring can do more: change memory mappings, talk to hardware, switch off interrupts. Code in an outer ring has to ask.

According to Wikipedia's protection ring entry, x86 has four levels, numbered 0 to 3, and "Ring 0 is the level with the most privileges and interacts most directly with the physical hardware." Rings 1 and 2 "are rarely used." Linux, macOS and Windows use just two modes: the kernel in Ring 0 and everything else in Ring 3.

Diagram of x86 privilege levels: Ring 3 for apps and Ring 0 for the kernel are defined by the CPU; Ring -1 for hypervisors and Ring -2 for System Management Mode are informal labels

Why does a kernel crash take the whole machine down?

When an app in Ring 3 reads memory it shouldn't, the CPU raises a fault and hands control to the kernel. The kernel kills that one app and everything else carries on.

When the kernel itself faults, there's nothing above it to hand control to. As Wikipedia puts it, if a processor faults in kernel mode, "most operating systems will halt the system with an unrecoverable error."

Linux reports these as an "Oops." The kernel's own bug-hunting guide shows one starting with "BUG: unable to handle kernel NULL pointer dereference." That's exactly the kind of crash Ring -1 Kernel Surgeon was built to catch.

So what is "Ring -1"?

It's the nickname for the extra level added by hardware virtualization. Wikipedia notes that x86 hardware virtualization (Intel VT-x and AMD's SVM) "is referred as 'ring −1'". It also lists System Management Mode as "ring −2" and the Intel Management Engine and AMD's security processor as "ring −3." None of these negative numbers is a real ring number in the CPU. They're shorthand for "runs underneath the kernel."

Software that runs there is a hypervisor, also called a virtual machine monitor. Wikipedia's hypervisor entry describes it as software that "creates and runs virtual machines" and calls it "the supervisor of the supervisors."

What are Type 1 and Type 2 hypervisors?

The split goes back to Robert Goldberg's 1973 thesis, per the same entry:

TypeRuns onExamples
Type 1 ("bare metal")Directly on the hardwareHyper-V, Xen, VMware ESXi
Type 2 ("hosted")On top of a normal OS, like any appVirtualBox, VMware Workstation

The line blurs. Linux's KVM is a kernel module, and the entry says it "effectively convert[s] the host operating system to a type-1 hypervisor." Ring -1 Kernel Surgeon is Type 1: it boots first and then starts Linux as its only guest.

Why did x86 need new hardware for this?

In 1974, Gerald Popek and Robert Goldberg set out three rules for a proper virtual machine monitor, summarised on Wikipedia:

  • Equivalence: a program should behave "essentially identical" to how it behaves on real hardware.
  • Resource control: the monitor "must be in complete control of the virtualized resources."
  • Efficiency: most instructions must run directly, without the monitor stepping in.

Older x86 chips broke these rules. The same entry says the Pentium had 18 instructions that were sensitive but not privileged: they behaved differently in a guest without trapping, so a hypervisor couldn't catch them. Early hypervisors worked around this by rewriting guest code on the fly, a technique known as binary translation.

Hardware fixed it. According to Wikipedia's x86 virtualization entry, Intel and AMD added hardware support "in 2005 and 2006." The first VT-x chips were two Pentium 4 models in November 2005, and the first AMD-V chips were Athlon 64s in May 2006, per Wikipedia's virtualization entry.

How does a hypervisor catch what the guest does?

The guest kernel runs as if it were in Ring 0, but certain events force a VM exit: the CPU stops the guest and jumps to the hypervisor. The hypervisor decides what to do, then resumes the guest.

Ring -1 Kernel Surgeon's architecture notes show this in practice on AMD hardware. A control block called the VMCB lists which events cause an exit: the CPUID instruction, reads and writes of one CPU settings register (EFER), a special VMMCALL instruction, and three kinds of exception, including page faults. The hypervisor runs the guest with the VMRUN instruction and handles each exit in a loop.

It also uses the exits to stay hidden. When Linux asks the CPU whether it supports virtualization, the hypervisor intercepts the question and answers no.

What are nested page tables?

A virtual machine thinks it owns physical memory, but it doesn't. Without help, every memory access would need translating twice. Wikipedia's second level address translation entry explains that this "increases the cost of memory access." Before hardware help existed, hypervisors kept "shadow page tables" in software.

Second level address translation puts the second step in hardware. Intel calls it Extended Page Tables, introduced with its Nehalem chips. AMD calls it Rapid Virtualization Indexing, known as Nested Page Tables during development.

The same tables decide what a guest can see at all. Ring -1 Kernel Surgeon marks its own code and its 2 GiB model as missing from Linux's view, so even a buggy kernel can't overwrite them.

FAQ

What is Ring 0?

The most privileged level on an x86 CPU, where the operating system kernel runs. Code there can access all memory and hardware.

Is Ring -1 a real CPU ring?

No. x86 defines rings 0 to 3. "Ring -1" is a common nickname for the hypervisor mode added by Intel VT-x and AMD-V.

What's the difference between a Type 1 and a Type 2 hypervisor?

A Type 1 hypervisor runs directly on the hardware (Xen, Hyper-V, ESXi). A Type 2 runs as an app on a normal operating system (VirtualBox, VMware Workstation).

Why can a kernel bug crash the whole computer?

The kernel runs at the highest privilege level the operating system has, so no other software layer is above it to catch its fault. Most systems halt instead of carrying on in an unknown state.

What is a VM exit?

The moment the CPU stops a guest operating system and hands control to the hypervisor, because the guest did something the hypervisor asked to intercept.

Reader poll

How do you use virtualization?

Vote to see results.

  • #cpu
  • #hypervisor
  • #virtualization
  • #x86
  • #explainer