microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.19k stars 806 forks source link

Nested virtualization unsupported on WSL2 while the CPU should. #11467

Closed Baitoven closed 4 months ago

Baitoven commented 4 months ago

Windows Version

Microsoft Windows version 10.0.19045.4291

WSL Version

2.2.2

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.150.1-microsoft-standard-WSL2

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

Windows 10 lastest release with Intel i5 13600KF (on MSI PRO Z790-P WIFI Motherboard) BIOS Updated to latest firmware (7E06vAC1(Beta version)) from 2024-02-27 Intel VT-x and VT-d enabled in BIOS. Virtualization shown as enabled in Windows Task manager. Start WSL from powershell: wsl: nested virtualization is not supported on this computer is displayed.

Expected Behavior

Running sudo kvm-ok inside WSL should return that everything is ok, and it's not.

Actual Behavior

Running sudo kvm-ok inside WSL returns INFO: Your CPU does not support KVM extensions KVM acceleration can NOT be used

Diagnostic Logs

WslLogs-2024-04-15_16-23-34.zip

github-actions[bot] commented 4 months ago

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs Download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an **administrative powershell prompt**: ``` Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1 Set-ExecutionPolicy Bypass -Scope Process -Force .\collect-wsl-logs.ps1 ``` The scipt will output the path of the log file once done. Once completed please upload the output files to this Github issue. [Click here for more info on logging](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-collect-wsl-logs-recommended-method) If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.
elsaco commented 4 months ago

@Baitoven your WSL version is older, but on 2.2.2 and kernel 5.15.150.1-microsoft-standard-WSL2 nested virtualization is available:

root@texas:~# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

and from dmesg output:

[    0.394474] KVM: vmx: using Hyper-V Enlightened VMCS
[    0.426816] kvm: already loaded the other module

kvm module info:

root@texas:~# modinfo kvm
name:           kvm
filename:       (builtin)
license:        GPL
file:           arch/x86/kvm/kvm
author:         Qumranet
parm:           tdp_mmu:bool
parm:           mmio_caching:bool
parm:           nx_huge_pages:bool
parm:           nx_huge_pages_recovery_ratio:uint
parm:           flush_on_reuse:bool
parm:           ignore_msrs:bool
parm:           report_ignored_msrs:bool
parm:           min_timer_period_us:uint
parm:           kvmclock_periodic_sync:bool
parm:           tsc_tolerance_ppm:uint
parm:           lapic_timer_advance_ns:int
parm:           vector_hashing:bool
parm:           enable_vmware_backdoor:bool
parm:           force_emulation_prefix:bool
parm:           pi_inject_timer:bint
parm:           mitigate_smt_rsb:bool
parm:           halt_poll_ns:uint
parm:           halt_poll_ns_grow:uint
parm:           halt_poll_ns_grow_start:uint
parm:           halt_poll_ns_shrink:uint
Baitoven commented 4 months ago

@elsaco I don't feel like my issue is version related, tbh. I've tried today to update to WSL v2.2.2, which did not change anything. In my opinion, the issue is hardware related : somehow virtualization features from my CPU are not handled by WSL (but are by Windows, since WSL is working)

github-actions[bot] commented 4 months ago
Diagnostic information ``` .wslconfig found Custom kernel found: 'C:\Users\Adrien\bzImage' Detected appx version: 2.2.2.0 Unexpected format in optional-component.txt: State : DisabledWithPayloadRemoved ```
Baitoven commented 4 months ago

WslLogs-2024-04-16_08-41-55.zip New logs removing previous logs unexpected format

github-actions[bot] commented 4 months ago
Diagnostic information ``` .wslconfig found Custom kernel found: 'C:\Users\Adrien\bzImage' Detected appx version: 2.2.2.0 ```
zcobol commented 4 months ago

@Baitoven you might have to install Hyper-V in order to use nested virtualization inside WSL.

Baitoven commented 4 months ago

@zcobol nested virtualization in WSL2 is supposed to use KVM to run, not HyperV. In my knowledge KVM does not use HyperV and HyperV might even cause some issues. I've already tried enabling HyperV on Windows side, but it does not seem to change anything.

zcobol commented 4 months ago

@Baitoven You're using Win10 and for nested virtualization in WSL you need Win11. See https://learn.microsoft.com/en-us/windows/wsl/wsl-config for details.

nestedVirtualization | boolean* | true | Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11.
Baitoven commented 4 months ago

@zcobol alright. As simple as that. Thanks for that I was indeed missing this piece of information.