# llm.asm Ring -1 Kernel Surgeon: 2B Model Patches Linux Crashes Live

> Source: <https://explainx.ai/blog/llm-asm-ring-1-kernel-surgeon-minicpm5-live-linux-patch-november-2026?utm_source=rss&utm_medium=feed&utm_campaign=blog>
> Published: 2026-11-29 00:00:00+00:00

**Recommendation:** Keep LLM-driven kernel remediation outside the kernel tree and gate any patch through a static x86-64 validator before writing bytes, as Ring -1 Kernel Surgeon does; treat NOP patches and multi-second freezes as demo-only, not production fixes.
More in the playbook "Running AI in production": <https://wpnews.pro/playbooks/production-ops>

**Alexey Fateev shipped phase 4 of [llm.asm](https://github.com/alesha-pro/llm.asm?ref=explainx): a freestanding AMD SVM hypervisor that sits in Ring -1 under Linux, catches a kernel fault before `panic()`, runs a **MiniCPM5-2B** checkpoint, and can **overwrite the faulting instruction bytes in guest physical memory** — then resume the guest **without a reboot.** The [README](https://github.com/alesha-pro/llm.asm?ref=explainx) calls the subproject **04-ring1-kernel-surgeon**; the author brands it **Ring -1 Kernel Surgeon** in a [November 27, 2026 post](https://nitter.gq/superalesha/status/2126420450737610808?ref=explainx).

This is a **QEMU/KVM research demo** with a `/proc/surgeon_crash` test module — **not** a supported way to harden your fleet. It matters because it shows where **small open models plus virtualization** could intersect with **kernel safety**, the same week [llm.asm''s bare-metal Qwen3 OS](https://explainx.ai/blog/llm-asm-qwen3-0-6b-pure-x86-64-assembly-14-kb-binary-vs-llama-cpp-2026) hit mainstream press.

## TL;DR

| Question | Answer | 
|---|---|
| Binary size? | **~75,424 B**`surgeon.elf` hypervisor (README);** not** including**~2 GiB** model weights | 
| Model? | **MiniCPM5-2B Q4_K_M** ,**GRPO** fine-tuned per README | 
| Guest OS? | **Linux 5.15** under**QEMU/KVM** with**nested AMD SVM** | 
| Demo crash? | Null-pointer write `*(u32 *)0 = 0xDEADBEEF` via test module | 
| Reported fix? | Replace **11 faulting bytes** with**11× NOP (0x90)** in ~**11.1 s** on**24 cores** | 
| Eval? | **119/122** pass@1 (**97.54%** ) vs**16.39%** base;**0** “dangerous continue” on held-out set per README | 
| License? | **MIT** (repo root) | 
| Use in prod? | **No** — seconds of downtime, NOP patches, synthetic faults only | 

## How the stack is built

The architecture file in `04-ring1-kernel-surgeon/ARCHITECTURE.md`, summarized by the repo README, describes a **Type-1 hypervisor** with **no host OS**:

- **NASM assembly plus freestanding zero-libc C** for the Ring -1 layer.
- **AMD SVM** with**nested page tables (NPT)** so the hypervisor can edit guest`.text` safely.
- **24 LAPIC SMP cores** exposed to the inference path in the demo configuration.
- **efifb HUD** for status on the host console during runs.

Linux remains **unmodified** at Ring 0. When a fault fires, the hypervisor **freezes** the guest **before** Linux prints a full **oops/panic** path, gathers **instruction bytes and registers**, calls the model, runs a **static x86-64 patch validator**, writes approved bytes into **guest RAM**, and issues **`VMRUN`**.

That pattern is closer to **“surgical halt and edit”** than to **kdump** or **livepatch** modules in upstream Linux — and it keeps the **LLM outside** the kernel tree, which matters for supply-chain stories like the [Linux “assisted-by” AI tag debate](https://explainx.ai/blog/linux-kernel-drop-assisted-by-tag-ai-patches-proposal-claimed-vs-verified-2026).

Linux terminal motif for Ring -1 kernel patch research under llm.asm

Agents that act on your behalf need rules. [See how explainx helps secure your agents →](https://explainx.ai/agentbeam?src=blog_note)

## The null-deref demo: what actually happens

The README and author thread describe a side-by-side test:

1. **Vanilla Linux** running the crash command**panics immediately** on a deliberate null dereference.
2. **Linux under Surgeon** hits the same module, but Ring -1**intercepts** the fault.
3. **MiniCPM5-2B** runs across**24 AVX2 cores** for about**11.1 seconds** .
4. The hypervisor writes **11 NOP bytes** over the faulting instruction via**NPT** .
5. Linux resumes, prints **`SURVIVED NULL-DEREF!`** , and**uptime does not reset** in the demo.

Important caveats the README itself supports:

- **NOP-ing** an instruction**does not repair program logic** — it avoids the trap.
- **11 seconds** of guest freeze is unacceptable for most online services.
- Tests use **injected faults** , not a random**NVMe driver** bug in the field.

For agents that might someday propose kernel edits, the lesson is **verification before apply** — the repo ships a **three-tier QEMU/KVM + Capstone verifier** and GRPO training that **rewards refusing** unsafe patches. That rhymes with [Anvio’s argument that LLMs should not get direct git push](https://explainx.ai/blog/anvio-llms-cannot-commit-push-architecture-policy-november-2026), but here the enforcement is **virtualization + static validation**, not policy text.

## What 97.54% pass@1 does and does not mean

The README''s **122 held-out scenarios** include:

- Cases that need a **byte patch** .
- Cases that should **delegate** to Linux''s own handlers.
- Cases that must **halt** rather than continue — e.g.**unsafe spinlock** states.

**Pass** means the model chose the **documented correct action**, not that Linux always behaved as if the original bug never existed. The README reports **0% dangerous continues** on that set — strong for a bench, **not** a proof of security in the open internet.

Compare the **base MiniCPM5-2B** at **16.39%** on the same suite: fine-tuning moved the needle, but **three failures** on **122** synthetic cases still imply **catastrophic risk** if one wrong patch ships on real hardware.

Builders evaluating **MiniCPM** elsewhere should read our [BotPsy on-device agent benchmarks](https://explainx.ai/blog/botpsy-0-8b-on-device-agent-qvac-apache-tool-use-2026) — a different task, but the same **small-model** economics.

## Phase 5 in the same repo: eBPF without a hypervisor

The README also documents **05-ebpf-jev**: a **21 KB INT8** recurrent model inside **Linux 6.12 eBPF LSM hooks** with microsecond-scale latency. It shows the author exploring **both** “model below the kernel” and “model inside the kernel.”

For production guardrails today, **eBPF LSM** and **livepatch** with human review remain the realistic paths; this hypervisor is a **teaching extreme**. Pair it with our [Vercel KVM escape discussion](https://explainx.ai/blog/vercel-kvm-zero-day-vm-escape-agent-sandboxes-2026) when you reason about **Ring -1 trust**.

## Training and verification pipeline (from the README)

Phase 4 is not only the **75 KB** hypervisor binary. The subdirectory documents a full **ML ops loop** for a **dangerous** action space:

- **Dataset** : hundreds of**synthetic crash scenarios** plus**distillation** scripts in`dataset/` .
- **SFT then GRPO** on**MiniCPM5-2B** in`training/` , with**TensorBoard** logging.
- **Three-tier verifier** : QEMU/KVM replay plus**Capstone** disassembly checks in`verifier/` so proposed patches cannot jump into**guest data** or**expand** beyond static rules.
- **Dashboard** : FastAPI telemetry for training and verifier passes in`dashboard/` .

The **97.54%** figure is **verifier-gated pass@1** on **held-out** scenarios — closer to **reinforcement learning with a hard safety filter** than to **"the model fixed Linux."** That is why **refusal** cases count as **wins**: the intended behavior on **spinlock crashes** is **do not patch**.

Readers comparing **agent benchmarks** should note **no mainstream SWE-bench score** here. The task is **machine-code editing under virtualization**, adjacent to **[ExploitBench-style](https://explainx.ai/blog/exploitbench-ai-exploit-generation-benchmark-2026)** security evals but **smaller** and **author-controlled**.

## Livepatch, kdump, and why Ring -1 is different

Linux already ships **mechanisms** for kernel recovery:

| Mechanism | What it does | How Surgeon differs | 
|---|---|---|
| **kdump** | Reboot into a capture kernel | **Saves state** , does not**resume** the sick kernel | 
| **kexec** | Fast reboot to a new kernel | Still a **boot** , not**in-place** edit | 
| **Kernel livepatch** | Applies vetted replacements | **Human-curated** ,**upstream** process,**symbol-based** | 
| **eBPF LSM (phase 5)** | Hook syscalls in-tree | **Policy** , not**rewrite of faulting `.text`** | 

Surgeon's demo optimizes for **uptime theater** in a **VM**: **freeze**, **NOP**, **resume**. Production **SRE** teams usually prefer **fail fast**, **drain**, and **roll** — especially after **[nginx2root-class](https://explainx.ai/blog/nginx2root-http2-rce-cve-2026-123007-xint-wiz-november-2026)** remote execution bugs where **silent continuation** is worse than **restart**.

If **agents** someday propose kernel diffs, the useful borrow from this repo is **verifier-before-apply**, not **LLM-below-the-kernel** deployment.

## Hardware and portability limits

The README targets **AMD SVM** with **nested virtualization** in QEMU. **Intel VT-x** shops cannot assume the same intercept path works unchanged. **Bare-metal** marketing in social posts still means **controlled metal inside KVM** for the documented demos — read **"bare-metal"** as **freestanding hypervisor**, not **"we patched your laptop kernel."**

**MiniCPM5-2B Q4_K_M** also locks you to a **specific open-weight lineage** — see [ColGrep's local search agent](https://explainx.ai/blog/colgrep-agent-2b-local-code-search-cuts-claude-code-tokens-34-percent-2026) for a different **2B** use case with **measured token savings**, not **kernel bytes**.

## How to try it (lab only)

From the repo root:

```
git clone https://github.com/alesha-pro/llm.asm.git
cd llm.asm/04-ring1-kernel-surgeon
make hv
python3 verifier/kvm_verifier.py --selftest
```

Follow `04-ring1-kernel-surgeon/README.md` for **nested SVM**, **initramfs**, and **VNC demo** scripts. Requirements include **AMD SVM**, **QEMU/KVM**, and downloads for **MiniCPM5** weights — not a five-minute laptop demo.

If you only need **fast CPU LLM inference**, stay with **phase 1** or [llama.cpp](https://explainx.ai/blog/llama-cpp-v1-0-0-stable-libllama-libggml-semantic-versioning-what-changes-2026). If you want **mainstream coverage of the 24 KB OS**, see the **Update** on our [llm.asm Qwen3 post](https://explainx.ai/blog/llm-asm-qwen3-0-6b-pure-x86-64-assembly-14-kb-binary-vs-llama-cpp-2026).

## What developers are saying

[Hacker News](https://news.ycombinator.com/item?id=50684534&ref=explainx) had only two comments on the Tom's Hardware bare-metal thread when this post was reviewed. **dartharva** recalled that early **MS-DOS** shipped in roughly **12 KB**, framing tiny boot code as historically normal. **vrighter** noted that workloads larger than the OS were once typical. That thread did not debate Ring -1 patching. On [Tom's Hardware's comment section](https://www.tomshardware.com/tech-industry/artificial-intelligence/ai-enthusiast-deletes-linux-to-run-qwen3-on-a-24kb-pure-x86-64-assembly-os-28-000-times-smaller-than-model-system-boots-in-74-milliseconds-runs-llms-up-to-54-percent-faster?ref=explainx), one reader argued **OS overhead alone cannot explain a 54% decode gap** without controlled conditions — the same skepticism to bring to any bare-metal vs Linux table.

## Security and reliability limits

| Risk | Why it matters | 
|---|---|
| **Silent data corruption** | Skipping an instruction can leave **wrong kernel state** . | 
| **Patch latency** | Multi-second freezes break **HA** assumptions. | 
| **AMD-only SVM** | No Intel VT-x path in the README snapshot. | 
| **Supply chain** | A poisoned **Q4_K_M** file sits in the TCB below Linux. | 
| **False confidence** | **NOP patches** look like recovery in a**tweet demo** , not in**postmortems** . | 

Sandboxed execution layers for isolating experimental kernel hypervisor demos

For real incidents — **nginx HTTP/2 RCE**, **agent-written packages**, **kernel CVEs** — follow vendor advisories and patch cycles, as in our [NGINX2Root post](https://explainx.ai/blog/nginx2root-http2-rce-cve-2026-123007-xint-wiz-november-2026). This project does not replace that work.

If you run **agents with shell access** near sensitive hosts, use organizational controls; for agent-risk posts we link [AgentBeam](https://agentbeam.com/?ref=explainx) in the **what to do** section — here the practical step is **keep Surgeon in disposable QEMU**, not on the hypervisor that holds customer data.

## Related reading

*Binary sizes, pass rates, and timings come from the llm.asm README and the author''s November 27, 2026 post as of publication date; re-run the bundled verifier scripts before citing them in production docs.*
