Re: Bhyve finally got nested virtualization.

From: Wanpeng Qian <wanpengqian_at_gmail.com>
Date: Fri, 20 Nov 2026 01:33:32 UTC
On 11/18/26, Michael Dexter wrote:
> Please include prompt author provenance and to the extent possible, code
> provenance given the risk of contamination from projects like QEMU/KVM.
>
> Please also include your tests in separate reviews.

Done, here is where things are now.

Tests: they are in a review of their own, D61734. It is a small loader
(about 200 lines, in the style of bhyveload) and a script that run the
VMX tests of kvm-unit-tests in bhyve, every test in a VM of its own.
kvm-unit-tests itself is not copied; the README says how to build it.

Results: they are in the test plan of D61708, from real hardware (Xeon
Silver 4110). Of 81 tests, 34 pass, 32 are skipped by the tests
themselves because L1 is not offered the feature (EPT, VPID and so on),
and 15 fail. Each failure is listed there with its reason.

I also ran the same tests on Linux KVM, with the VMX features of its
virtual CPU cut down to what my change offers. 63 of the 81 tests give
the same result with the same number of checks on both. 11 pass on KVM
and not on bhyve; most of them need the MSR load/store areas, which are
not in this change. That comparison is in the test plan too, with one
caveat: the KVM run was on a different machine.

The tests already changed the code once. Their guests write to the
serial port without L1 intercepting I/O, which my first version did not
handle. D61708 was updated for that.

Size: D61708 is about 2200 lines, and D61709 is a small optional
speed-up on top. It is the smallest step I could find that runs Linux
with KVM as a guest, with guests of its own. It is off by default
behind a loader tunable. What is missing, and my estimate of how much
code each later review would be, is under "What comes next" in the
summary of D61708. The largest missing part is EPT for L1.

Provenance: I am the prompt author. The code was written with Claude
under my direction, from the nested VMX implementation in keelOS (my
own project) and from the Intel SDM. KVM was read for the overall
scheme and to learn what it needs from the CPU when it runs as L1. No
code was taken from KVM, QEMU or any other hypervisor. The summary of
D61708 says the same in more detail.

I know that an LLM-written change to vmm is a hard thing to accept, and
I do not expect it to be taken on trust. That is why I kept it small
and put the tests next to it. Review comments on D61708 are very
welcome, also ones that say the approach is wrong.


Wanpeng

On Thu, Nov 19, 2026 03:53 AM, Michael Dexter <editor@callfortesting.org>
wrote:

> Mark, Hayzam, Aryeh, Mario, Wanpeng, and others,
>
> Please post reviews of your nested bhyve projects or at a minimum post
> the diffs in canonical FreeBSD format.
>
> Please include prompt author provenance and to the extent possible, code
> provenance given the risk of contamination from projects like QEMU/KVM.
>
> Please also include your tests in separate reviews.
>
> How about we discuss these projects on Thursday's bhyve Production User
> Call at 10 AM Pacific? Call information is at callfortesting.org
>
> All the best,
>
> Michael Dexter
>
>
>