Windows VM how to support nested virtualization

I’ve been fighting with this for a couple of days. I have a windows VM created and running under incus with a gpu passed through. The issue i face is that a certain windows application requires hyperv and WSL to be enabled… which means i have to do nested virtualization. I can’t seem to find the correct qemu flags to enable that.

Also whenever i shutdown the system the gpu pass through seems to cause some issues because the KVM will crash talking about not being able to write to registers and memory addresses.

I’ve tried running with -cpu host to no avail.

Invalid read at addr 0x381800000000, size 1, region '(null)', reason: rejected
Invalid read at addr 0x381800000001, size 1, region '(null)', reason: rejected
Invalid read at addr 0x381800000002, size 1, region '(null)', reason: rejected
Invalid read at addr 0x381800000003, size 1, region '(null)', reason: rejected

Some of my config

    -device intel-hda
    -device hda-duplex
-cpu host,hv_passthrough,topoext=on
-enable-kvm
-smp 8,sockets=1,cores=4,threads=2
-smbios type=2
-d guest_errors

Any thoughts would be greatly appreciated.

The Proxmox wiki gives clues.

echo "options kvm-amd nested=1" > /etc/modprobe.d/kvm-amd.conf

This seems to fix the bluescreen you see as well:

echo "Y" > /sys/module/kvm/parameters/ignore_msrs
 root@proxmox:~# cat /sys/module/kvm_intel/parameters/nested                    
 Y

Hope that helps!

Well i pulled out the GPU so no pass though and played around with it for hours and i can’t seem to get the cpu usage on the host down.
I did a ‘perf’ run and i plugged the results into claude.ai…

I see we still have high CPU usage, but there’s progress - the pattern is different from before. Looking at the perf report:

1. **CPUIdle operations are a major consumer** (48.81%, 48.80%, 48.17%, 46.29% for various idle-related functions). This suggests the host is trying to enter idle states but isn't able to stay there effectively.
2. **I/O wait overhead is significant** (33.56% in io_idle). This indicates the VM is causing a lot of I/O operations that are interrupting the CPU idle states.
3. **System calls and KVM virtual CPU management** (26.xx% entries) are still considerable but lower than in your previous profile.
4. **ACPI processor state transitions** are still high (11.33%).

These are the current options that i have tried.

    -enable-kvm 
    -cpu
    host,+topoext,+x2apic,+avic,hv_time=on,hv-tlbflush,hv-ipi,hv-frequencies,hv-reenlightenment,hv-vpindex,hv-synic,hv-stimer,hv_relaxed,hv_vapic,hv_vpindex,hv_spinlocks=0x1fff,hv_stimer,hv_synic,hv_reset
    -smp 8,sockets=1,cores=4,threads=2 -rtc base=localtime,driftfix=slew -global
    kvm-pit.lost_tick_policy=delay -device amd-iommu

So after a lot of testing and research it turns out this is not possible right now.
When you pass a GPU through to a windows VM with nested virtualization enabled the nvidia drivers will return a code 42 which is a form of a crash.

If you set your hypervisor to NOT support nested virtualization you can run GPU acceleration in windows.