r/freebsd • • 2d ago • Bravo 1 Heartwarming 1

AI Bhyve finally got nested virtualization.

Here we go again.

After a full month of work,night and day,I've implemented the nested virtualization for (qemu) + bhyve :

https://github.com/Marietto2008/freebsd-src/tree/vmm-nested-16

It works with every permutation of FreeBSD,Linux and Windows,as you can see from the pictures below :

Permutation 1 :

L0=FreeBSD 16.0-CURRENT
L1=Windows 11
L2=FreeBSD 15.2 (on top of Hyper-V and WSL2)

https://ibb.co/kTRL2cv :

Permutation 2 :

L0=FreeBSD 16.0-CURRENT
L1=KUbuntu-Noble-Wayland-KDE
L2=FreeBSD-15.1-RELEASE

https://ibb.co/6JZWPrpz :

Permutation 3 :

L0=FreeBSD 16.0-CURRENT
L1=FreeBSD-15.1-RELEASE
L2=Linux omarchy

https://ibb.co/LDSDkXJF :

This has been the most complicated, delicate, treacherous project that I've worked on so far. But what matters is that I had fun and I've learnt a lot.

Here is a small kit for replicating the project on your PC :

https://github.com/Marietto2008/bhyve-nested-strumenti/tree/main/kit

If you try it, please attach the manifest and the smoke-test output.

For the record, my host is consumer hardware: an i9-9900K on a Gigabyte Z390 AORUS PRO, BIOS F12g (2020), running FreeBSD 16-CURRENT. The CPU has VMCS shadowing but no APICv and no posted interrupts, and that shapes the results below.

**On AI use, since that is what the policy discussion is about.**

Code, the test scripts and the performance report were produced with Claude 5.5 with the help of Astra 6. Design reviews during development were also done by AI models, not by people. KVM (GPL) was studied for its behaviour, never copied. Commits carry a "Co-Authored-By: Claude" line. Nothing here has had independent human review yet, and I'd welcome it.

From here on I'll post one item at a time, when there is something new, instead of long reports. Raw data and scripts are in kit/full-report/.

56 Upvotes

40 comments sorted by

8

u/CodeDriveRepeat 2d ago • Bravo

First, it helps to know your audience. This looks like interesting experimental work, but I’d be cautious about recommending it to FreeBSD users in its current state. It replaces the stock hypervisor module and requires root, so people need a clear basis for trusting the code and understanding its effects.
Before I’d consider running it, I’d want exact source revisions pinned, provenance and licensing clearly documented, clean-machine build and reproduction steps, and security testing of the modified hypervisor and guest isolation. The reported testing is on one machine, and the project lists stability issues, so I’d describe it as experimental for now.
Keep developing it, but make sure you understand and can review the code and the tools involved, including AI-generated contributions. Licensing deserves particular care: identify the licenses for each component and patch, retain required notices, and document how changes relate to upstream projects.
These steps would help others evaluate and reproduce the work. Right now, the results are promising, but they’re still at the “works on my machine” stage.

2

u/Opposite_Benefit_675 2d ago

Sure. It should not be run on a daily basis machine. It needs a secondary machine for testing. And if you have an AI account,you can ask it to improve the code. I took it for granted.

2

u/CodeDriveRepeat 2d ago

You can probably just paste what I said into you Claude project and ask it if what I said was right and what it thinks you could do about it.

3

u/Opposite_Benefit_675 2d ago • Heartwarming

Thank you, this is fair and useful feedback, and I agree with it.

You're right that it is experimental. It replaces the stock vmm(4) module,it needs root, it has only been tested on my own machine (i9-9900K,FreeBSD 16.0-CURRENT), and there are known stability issues. I will say so at the top of both READMEs, with the list of known issues, so nobody runs it expecting a finished product.

  1. Pinned revisions. A tag for each published state, with the exact upstream base it applies to (FreeBSD main commit,QEMU version) and the list of my commits on top of it.
  2. Provenance. The work started from abhichavali's FreeBSD and QEMU forks; I'll document what comes fr how each change relates to upstream FreeBSD and QEMU, including the in-progress upstream nested VMX review.
  3. Licensing. The kernel and bhyve parts stay under FreeBSD's BSD-2-Clause,the QEMU parts under GPL-2.0-or-later as QEMU requires. Existing notices are kept, SPDX tags go on nists the license of each component and patch.
  4. AI involvement. This code was written by Claude and reviewed by Astra.
  5. Reproduction. A script that starts from a clean FreeBSD 16-CURRENT install (a VM is fine), fetches the kernel module and QEMU, and checks the results, with the expected output documented.
  6. Security and isolation. I'll document which parts of the attack surface change (the nested VMX emulation and the new ioctls), what has been tested so far and what hasn't. Fuzzing the vmm ioctls is on the list.

Until all of that is in place, please treat it as "works on my machine",as you say. If anyone wants to a throwaway VM or on a test machine, results and bug reports are very welcome.

2

u/Opposite_Benefit_675 1d ago

**The bug.** With a KASAN kernel in the L1, the L1 panicked as soon as its L2 issued INVEPT:

```

panic: Unaligned free of 0xfffff80228959000 from zone ... (malloc-4096)

uma_dbg_free <- free <- vept_free_level <- vept_root_wipe <- vmx_vept_invept <- nested_invept

```

The shadow EPT tables were allocated with `malloc_aligned()`. The child tables were then found again through the direct-map alias of their physical address, and freed with that alias. Without KASAN, UMA on amd64 normally hands out direct-map pages, so the two pointers matched by accident; with KASAN they don't. The fix (commit `ec105b041f72`) allocates the tables as physical pages used through the direct map, the way pmap does with its page tables.

**How it was tested**

The test stack, on one machine (an i9-9900K):

- the host (L0) runs this project's `vmm`;

- the L1 is FreeBSD 16-CURRENT built from the branch, with the sanitizer kernel and a `vmm-restore.ko` built the same way;

- inside the L1 runs the kit's smoke test: its L2, a FreeBSD 15.1 guest, loads vmm (VMXON) and boots an L3 kernel up to the root-mount prompt.

So every VMX instruction of the L2 goes through the L1's nested code, under the sanitizer.

| L1 kernel | result | sanitizer reports |

|---|---|---|

| GENERIC (baseline) | all passed | — |

| KASAN, before the fix | panic above | 1 (the bug) |

| KASAN, with the fix | all passed | 0 |

| KMSAN, with the fix | all passed | 0 |

With four levels everything is slow: the L3 needed about 10-11 minutes to reach the prompt. So the runs used longer time limits than the stock smoke test; that was the only change to the script.

The testing also turned up a bug in the kit itself. The smoke test's console reader turned echo off only after bhyve had started. A freshly opened nmdm starts with echo on, so for a moment the guest got its own output back as keystrokes. My own L1 launcher had the same pattern, and there it was enough for the loader menu to pick "Boot Single user". The reader now turns echo off before the VM starts, both on the host and inside the L1; the fixed `kit/smoke-test.sh` passes on the host.

**Where to find them**

- **Kernels:** https://github.com/Marietto2008/bhyve-nested-strumenti/releases/tag/nested-sanitizers-v2

- `kernel.nested-kasan.tar.xz` (66 MB) and `kernel.nested-kmsan.tar.xz` (118 MB): each kernel with all its modules, including `vmm-restore.ko`. These are the exact binaries that passed: the modules' sha256 match the ones loaded in the test.

- `SHA256SUMS`: check with `sha256sum -c SHA256SUMS`.

- Release `nested-sanitizers-v1` is superseded: its module still has the bug. Don't use it.

- **Source:** `Marietto2008/freebsd-src`, branch `vmm-nested-16`, commit `ec105b041f72`.

- `sys/amd64/conf/NESTED-KASAN` and `NESTED-KMSAN`: `GENERIC` plus `options KASAN` / `options KMSAN`.

- `tools/nested/build-sanitizer.sh`: rebuilds both, so you don't have to trust my binaries.

**How to use them**

Not on your host. Use a FreeBSD 16-CURRENT VM that has nested VMX (bhyve with `-o x86.nested_virt=true` and `-w`):

  1. unpack the archive into `/boot`;
  2. boot it once with `nextboot -k kernel.nested-kasan`;
  3. `kldload vmm-restore`;
  4. run an L2 that uses VMX, for example `kit/smoke-test.sh` inside the VM.

A sanitizer report shows up as a panic, with a stack, on the console.

**What this is and isn't**

It is one functional test on one machine: it covers the code paths that this test exercises, not the whole module. There is still no fuzzing and no independent human review; `SECURITY.md` in the repository lists what is open. If you run the kernels and get a report, please open an issue with:

- the full console text;

- the output of `kit/host-manifest.sh`;

- the commit hash.

2

u/taosecurity seasoned user 2d ago

Can you say more about how you used Claude and Astra? Did Claude code and Astra reviewed?

2

u/Opposite_Benefit_675 2d ago

Exactly. Nice intuition. Astra is more expensive than Opus. I use it for consultations and Opus as the primary "programmer".

2

u/taosecurity seasoned user 2d ago

Have you tried Fable? I had usage to spare last night before my reset, so I had Fable look over work I had done with Opus. Fable found a bunch of stuff to fix in my projects, which I had Opus implement.

3

u/Opposite_Benefit_675 2d ago

Nop. Fable for me is too much expensive. I found that the best combination in terms of cost / benefit ratio is to use opus 5.5 as main "programmer" and Astra 6 for consultations.

2

u/jjccs 2d ago

thank you sir for you efforts ! really interesting to see what you can do with help of AI to bring interesting features to FreeBSD. Even though we know the kernel team wont accept AI generated codes.

1

u/grahamperrin Claude user 2d ago

… the kernel team wont accept AI generated codes.

Here, for example:

https://www.reddit.com/r/freebsd/comments/1xhfzmf/comment/19rsir36gd3hh/?context=1

… all three co-authors were Anthropic Claude.

2

u/Opposite_Benefit_675 1d ago edited 1d ago
My code has never been taken into consideration by
any FreeBSD developer. On the ML I've always been treated like 
a greasy rag by everyone except one dev. Your comment 
indirectly offends me (but it's not your fault). It offends me 
to see that some people use Claude to submit code and they are 
considered, while I am treated terribly. I have proof of what I 
say. See for yourself in the ML and on forums.freebsd.com. 
Reddit is different,is a better place when it comes to getting 
proper recognition for one's efforts. Are you signed on the 
various FreeBSD mailing lists ? Are u signed on 
forums.freebsd.org ?

1

u/grahamperrin Claude user 1d ago

… Are you signed on the various FreeBSD mailing lists ? …

Too many (I don't know how many).

I should probably describe myself as a lurker. The vast oversubscription is to compensate for the combined inadequacies of archiving, indexing, and so on. I simply can not find content, including my own content, when I need it, so – without planning this outcome – I have learnt to treat e-mail as a legacy form of communication.

Yesterday's 'pkg-be: integral' was a very rare post from me.

The last time I attempted to find something that was not already known to me, I used Claude.

My day job is a little different, in that I'm required to use e-mail for some stuff, but generally, I avoid e-mail like a plague.

1

u/grahamperrin Claude user 1d ago

… Are u signed on forums.freebsd.org ?

No, I chose to quietly disappear in October 2024 – https://forums.freebsd.org/tags/absence/ (tag: absence):

Log out everywhere; from all devices

The unspoken implication was that I'll not log in again.

In the two years since then, I have occasionally growled at individuals in The FreeBSD Forums, from here in Reddit, however I have never been tempted to log in. It's not unreasonable to growl when (for example) I see people lying about me; and since I willingly took myself away, it wouldn't be fair to ask moderators to intervene on my behalf.

I can't force people to retract lies; it's The Internet. I mean, it's not a problem with the Forums per se.

On a (very) happy note: a few days ago, with an AI tool, I sloppily mistyped something and I stumbled across my former presence, in the Forums, summarised in exactly the way it should be. I rocked with laughter. I can't recall what I mistyped … I can't reproduce the search result, today, but I recognised my own words a few days ago. The origin of those words will move, or change, soon enough.

1

u/grahamperrin Claude user 1d ago

… treated terribly. …

Occasional mistreatment does not go unnoticed.

I have also seen you mistreated in Reddit. I recall intervening when someone idiotically tried to justify their mistreatment of you based on a demonstrably false assumption. This anti-AI protestor had her comeuppance around two weeks later when she failed to big herself up by trying to get shitty with me; she's permanently blocked.

I cannot overstate the positive value of blocking. It's the polar opposite of what people sometimes recommended in The FreeBSD Forums (I was encouraged to not use the ignore feature of XenForo), but there's a wealth of evidence elsewhere to support the value of obstructing Negative Nellies.

I wrote about knowing one's enemy in April 2024 in The FreeBSD Forums. Now: attempting to engage with some types of enemy is futile; I know their value before they open their mouths; they're silenced before they can speak; and the Internet, which is colossal, is an infinitely better place without their arm-waving.

Come il ferro è consumato dalla ruggine, così gli invidiosi dalla loro stessa passione.

I should close this line of discussion with a simple question: do you have a Mastodon account?

Thanks

11

u/CodeDriveRepeat 2d ago • This


Sweet! Great job. Keep up the good work. I’ll check it out. And add a star.

2

u/grahamperrin Claude user 2d ago

scan of /Marietto2008/freebsd-src on github.com

  • score 75 (B)
  • 75 = muy
  • B = bueno, as pictured above.

I changed the flair (tag) of your post:

  • from discussion
  • to AI.

2

u/CodeDriveRepeat 2d ago

100% Claude. I’ll fork out and check it out. See what can be fixed.

2

u/Opposite_Benefit_675 2d ago

I used Opus 5.5 and Astra 6.

2

u/CodeDriveRepeat 2d ago • Heartwarming


I think the dude is Italian. Gotta have the correct gif for that.

2

u/Opposite_Benefit_675 2d ago

Yes,I come from Italy.

1

u/grahamperrin Claude user 2d ago

¡MUY BUENO! 🎉 Congratulations on conquering nested virtualization! A month of night-and-day debugging deserves a celebration on this scale. 🇮🇹 🇫🇷 🇲🇽

Claude is French, isn't he?

3

u/Opposite_Benefit_675 2d ago

hahahahha. sure. he instead of it.

1

u/fazelesswhite Hayzam – author of Sylve 1d ago

I think this is the fourth implementation of nested virtualization I've seen in the last six months or so. All of them have been written with the help of Claude/LLMs (which I have absolutely no issue with), but with the exception of one (https://reviews.freebsd.org/D61708), the others haven't really been presented in a coherent, reviewable form.

Just my two cents as a -src committer: if you want a feature, regardless of how big or small, to eventually land, it helps enormously to engage with the community first. IRC, the FreeBSD Discord, and other channels are excellent places to discuss ideas, get feedback, and find out whether someone is already working on the same thing.

Imagine how much more productive it would've been to point those LLMs at reviewing and improving D61708 instead of starting yet another independent implementation around the same subject.

2

u/Opposite_Benefit_675 1d ago edited 1d ago
Developers ignore my work and even treat me badly because I use AI,
and older developers don't like that. To which I replied that I 
understand I'm not, but I'm one thing, and the code I produce is 
another. They could also take some parts of the code I produce 
instead of ignoring me or treating me badly and rejecting 
everything entirely. No, I don't know how to discuss how the code 
was implemented, but I don't think it's necessary either. It would 
be enough for them to take some parts of the code and discuss them 
among themselves or use Claude like I did to fix it. They don't do 
any of that. Furthermore, they've never even given me proper credit 
for what I've done, unlike Reddit users, as you can see, who are 
much more understanding of the enormous work I did for me and for 
the community. This is not the first job I did. 6 months ago I completed the work of Abinav Chavali to use bhyve as an 
accelerator for qemu + the nvidia passthru :

https://forums.freebsd.org/threads/enabled-the-nvidia-gpu-
passthrough-inside-a-linux-virtual-machine-via-qemu-accelerated-
with-bhyve.102901/

https://forums.freebsd.org/threads/booted-debian-and-freebsd-15-
using-qemu-accelerated-with-bhyve-vmm-for-the-first-time-this-is-
an-epic-milestone-for-the-community.102735/

And now I'm working on another interesting project that I saw no 
one is working. FreeBSD deserves the best technologies all 
around and it will have them,at least on my machine. If they don't 
care about my code,I will use it on my machine only. I don't have 
problems. Today the quality of the code produced by Claude and
Astra is not so bad compared to the code produced by humans.

2

u/fazelesswhite Hayzam – author of Sylve 1d ago

> Developers ignore my work and even treat me badly because I use AI, and older developers don't like that.

Regardless of whether you use AI, nobody deserves to be treated badly or harassed for contributing. I'm sorry you experienced that, and that kind of behaviour is explicitly against the FreeBSD project's Code of Conduct (https://www.freebsd.org/internal/code-of-conduct/).

However, I think there's a distinction to be made between how someone is treated and how their code is received or reviewed. Criticism of code, rejection of a patch, or a lack of interest in a particular implementation isn't necessarily hostility towards the person who wrote it, nor is it necessarily because AI was involved.

> No, I don't know how to discuss how the code was implemented, but I don't think it's necessary either. It would be enough for them to take some parts of the code and discuss them among themselves or use Claude like I did to fix it.

I think this is a fundamental problem, though. FreeBSD contributors are, for the most part, volunteers who dedicate their time to the project. You cannot reasonably expect them to take code they didn't write, reverse-engineer how it works, identify which parts are useful, discuss it among themselves, and then potentially fix or rewrite it for you. That's a significant amount of work, and they're doing it voluntarily.

If you're submitting code upstream, you should be prepared to explain the design, justify the implementation choices, discuss trade-offs, respond to review feedback, and make changes when requested. Using AI to help you write code is perfectly fine, AFAICT, although the project's official stance on this still isn't entirely clear to me. I'm increasingly seeing reviews where I can't really distinguish whether the code was written by AI or a human, and personally, I think that's the best-case scenario. But using AI doesn't absolve you of the responsibility of understanding and maintaining that code. "Ask Claude to explain it to me" can be a useful learning tool, but it shouldn't be a substitute for actually understanding what you're proposing to merge into the project.

And this is precisely why engaging with the community early matters. You can discuss the problem you're trying to solve, your proposed approach, and whether anyone is already working on it before spending months building an implementation. You might get useful feedback, avoid duplicating existing work, and end up with something that is much easier for others to review and potentially accept.

Nobody is obligated to accept a contribution simply because a significant amount of effort went into producing it. Nor is anyone obligated to review or salvage every contribution. The goal is to get technically sound, maintainable code into FreeBSD, not simply to acknowledge the effort that went into generating it.

If you want to use the code on your own machine, that's absolutely your prerogative. But upstream acceptance is a different matter, and it comes with expectations around technical quality, reviewability, maintainability, and the ability of the contributor to engage with the review process.

2

u/Opposite_Benefit_675 1d ago edited 1d ago

>However, I think there's a distinction to be made between how someone >is treated and how their code is received or reviewed. Criticism of code, >rejection of a patch, or a lack of interest in a particular implementation >isn't necessarily hostility towards the person who wrote it, nor is it >necessarily because AI was involved.

Yes,I have proof that a lot of them don't like AI. This is very clear and a lot of them don't hide it. A lack of interest happens every time I make a new implementation. Remove the word particular from your sentence,because it happens everytime. I know that they don't hate it as a person,but they hate me because I love AI.

>I think this is a fundamental problem, though. FreeBSD contributors are, >for the most part, volunteers who dedicate their time to the project. You >cannot reasonably expect them to take code they didn't write, reverse->engineer how it works, identify which parts are useful, discuss it among >themselves, and then potentially fix or rewrite it for you. That's a >significant amount of work, and they're doing it voluntarily.

It is precisely because they are volunteers that if they don't use AI, they will never be able to create implementations of new and complex features like the nested virtualization. If we had to wait for them to write it all using just their own brains, we'd still be here 10 years from now. That’s why I say it’s faster for them to at least consider some parts of the code that someone else has written for them. I know that's still a lot of work, too. However, I imagine it's faster than writing the entire implementation of a massive project relying mostly on non-AI-generated code,on a voluntary basis, too.... If that weren't the case, you'd have to explain to me why, before AI was invented, FreeBSD didn't even have the GPU passthrough (anyway, it was actually me and Corvin—who managed to get it working inside a Linux and Windows VM : yes,tests have been done using my RTX 2080 ti), nested virtualization, bhyve used as an accelerator for QEMU, or other features that a modern operating system like Linux already had. Now that AI is here, though, they feel a fire under their feet and are working much harder, out of fear that AI itself might spell the end of the operating system they love."

>If you're submitting code upstream, you should be prepared to >explain the design, justify the implementation choices, discuss trade->offs, respond to review feedback, and make changes when >requested. Using AI to help you write code is perfectly fine...

It is not fine at all that I use AI. They want that I'm a programmer. They don't want that I use AI to discuss about the code. It makes no sense since they can use AI just as me,so they have rejected again the code that I have proposed.

-> If you're submitting code upstream..

If my code has always been rejected when I talked about the projects that I have implemented on the ML and on the forums,how can you expect that it will be accepted in upstream ? But even if it were accepted, given the reception I've always gotten from them, I have no desire to submit anything upstream at all.

-> And this is precisely why engaging with the community early matters. You can discuss the problem you're trying to solve, your proposed approach, and whether anyone is already working on it before spending months building an implementation. You might get useful feedback, avoid duplicating existing work, and end up with something that is much easier for others to review and potentially accept.

I'm not a programmer. I can't talk with high skilled developers using my knowledge only. I can do it only using Claude. But they don't want that I use it because they can do the same (but really a lot of them will not do it). My real job is totally different. Despite this, I can create new and interesting new features that FreeBSD needs and a lot of good code going to waste because of their rigid mindset about how work should be done. Or maybe it would be better to say, how work used to be done before AI.

--> duplicating existing work.

Using AI I'm able to make a new feature faster than them. Look. I have a working implementation of the nested virtualization since 1 month. They are still far behind me. I would not talk about duplicating work,but more of wasting of useful code and time because there isn't a productive collaboration between me (and not only me,I would say us (as AI users) and them (as old developers).

2

u/CodeDriveRepeat 1d ago • Bravo

I agree, they should state it the way I would have. I think you do need a basic understanding of what you’re doing because otherwise you’re liable to introduce bugs or security holes or other issues that could affect many users. I understand to a point what they are trying to protect against, but discouraging ai is also behind the times. So there needs to be a middle ground where maybe the community says something like this is the right idea, but it needs to consider the following things before broader acceptance. Maybe there could even be a place where people who don’t know what they don’t know share things with those that do.
Those that do can review their POCs let’s call them and then suggest where they need to be improved. Then they can share repos and others who know better can contribute and fix the bugs and holes, and get things integrated faster. A centralized idea center would be better that would probably encourage more sharing and eventually a better OS.

It’s probably better to be more welcoming to ideas than locking everyone out of the community because they’re not experts.

Just my two cents.

I’d be happy to review some of these things and give feedback. In fact I’d be happy to setup a GitHub org for this stuff if anyone is interested.

1

u/grahamperrin Claude user 5h ago

… Maybe there could even be a place where people who don’t know what they don’t know share things with those that do. …

r/freebsd should be one such place. It is, simply, an unofficial subreddit for the FreeBSD Project.

I sometimes have a problem with pseudo-moderators who try to make this place something that it's not.

2

u/CodeDriveRepeat 2h ago

Here, I created this org where people can share their code if they want. I put everything I would do as someone with experience into an agents.md that you can just take or add a new repo and it will be there.
If you think this is useful/helpful for this community I’ll keep it up and add anyone that wants to join.
@grahamperrin, you can be an owner if you wish.

https://github.com/r-FreeBSD

1

u/grahamperrin Claude user 1h ago

@grahamperrin, you can be an owner if you wish.

Things such as Reddit and Mastodon keep me more than busy enough, and I have my fingers in too many pies already (FreeBSD is just one of the pies), so I'll not join at this time, but good luck!

Thanks for the invitation.

Also, I like the icon 👍

1

u/grahamperrin Claude user 1d ago

… engaging with the community early matters. …

Intolerance and unkindness can cause a person to shrink back from early engagement. I have seen this happen more than once.

1

u/grahamperrin Claude user 1d ago

… I will use it on my machine only. …

I understand this sentiment.

Unrelated to bhyve: I have a vibe-coded patch that prevents kernel panics. For various reasons, I keep it to myself.

I might post something to one of the official lists, one day, however I don't expect a response. That's not to criticise the developers; it's simply how things are with some lists.

2

u/Opposite_Benefit_675 1d ago

Can u share the links of the other implementations that you have found ?

1

u/Such_One_406 2d ago edited 2d ago

What sanitizer methods did you give Claude to use?

2

u/Opposite_Benefit_675 2d ago

Sanitizers were used only in a narrow place, and the kernel itself has not been run under KASAN/KMSAN yet.

What was used :

- ASan + UBSan on userspace test benches built from the real kernel code. The benches banco-opnd, banco-opnd-s10 and banco-opnd-s11 live in bhyve-nested-strumenti, branch wsl2-freebsd. They extract the actual functions from vmx_nested.c and vmm_instruction_emul.c and compile them on stubs, with -fsanitize=address,undefined.

- They cover the path from vm_run through the nested exit handlers to the VMX instruction operand access and vm_copy_setup.

- Guest memory is a strict simulated MMU: non-contiguous pages, and #PF with the exact CR2.

- The latest bench runs 2492 cases, all correct, and the sanitizers report nothing.

- Mutation testing on the same benches. Deliberately broken variants of the code (53 in the latest stage, 34 and 41 in earlier ones) are all caught. This shows the benches can actually detect the kind of bug they target.

- Kernel debug options. The host kernel is built with INVARIANTS and WITNESS. To be precise: I have not verified that WITNESS was active during every campaign, and on 2026-11-28 it was off at run time (debug.witness.watch=-1).

- Diagnostic counters in the module. They must stay at zero; one example is a VMCS freed while still active. There are also DTrace probes on the nested paths.

- Functional tests. The kvm-unit-tests VMX tests, adapted to bhyve, plus KVM run as L0 as a behavioural reference on the same workloads.

What was not used :

- No KASAN or KMSAN kernel, so the nested module has never run under a kernel memory sanitizer.

- No sanitizer builds of bhyve or QEMU.

- No fuzzing of VMX exits, VMCS12 contents or the vmm ioctls.

The ASan/UBSan coverage is therefore limited to what the benches exercise. A KASAN/KMSAN run of the module and fuzzing are on the open list in SECURITY.md.

On "give Claude": the benches, the mutants and the sanitizer runs were designed and run by Claude, with design reviews by Astra, not by people. I directed the work and checked results on the hardware.

2

u/Opposite_Benefit_675 2d ago

There are now KASAN and KMSAN builds of the kernel, with the nested vmm module, ready to download.

Where to find them :

- The built kernels: https://github.com/Marietto2008/bhyve-nested-strumenti/releases/tag/nested-sanitizers-v1

- kernel.nested-kasan.tar.xz (67 MB): the KASAN kernel with all its modules, including vmm-restore.ko built with KASAN.

- kernel.nested-kmsan.tar.xz (118 MB): the same for KMSAN.

- SHA256SUMS: check it with sha256sum -c SHA256SUMS before using anything.

- The source and configuration they were built from: Marietto2008/freebsd-src, branch vmm-nested-16, commit 4b0bf9c0660a.

- sys/amd64/conf/NESTED-KASAN and NESTED-KMSAN: GENERIC plus options KASAN / options KMSAN, nothing else.

- tools/nested/build-sanitizer.sh: builds both from the same commit, so you don't have to trust my binaries.

How they are meant to be used :

Not on your host. Use them in a FreeBSD 16-CURRs the L1 hypervisor:

- unpack the archive into /boot;

- boot it once with nextboot -k kernel.nested-k

- inside it, run an L2 guest that uses VMX: the kvm-unit-tests VMX tests (branch bhyve-nested) or the L2 kernel of kit/smoke-test.sh.

Every VMX instruction the L2 executes then goesr the sanitizer. A violation shows up as apanic, with a stack, on the console.

Status :

Built on 2026-11-28 and not booted yet: my own runs come next, and I'll post the results in the release notes. If you get there first, even better.

This is experimental code, tested on one machinand SECURITY.md in the repository before running it.

What I'm asking for :

If you run them and get a KASAN or KMSAN report, please open an issue with:

- the full console text of the report;

- the output of kit/host-manifest.sh;

- the commit hash.

A report with a stack is worth more than "it works for me".

2

u/CodeDriveRepeat 4h ago

I think I should create an Agents.md for people who haven’t been programming since they were 8 like me and may not have an understanding of security necessities.
If anyone wants this let me know, I’ll create it and share it then your agent should do better.

1

u/nrgmilk 2d ago

Thank you a lot!

0

u/grahamperrin Claude user 2d ago

https://beige.party/@fuzzy/117694964510634915 – u/Opposite_Benefit_675 if anything there needs adjustment, please let me know.